Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I avoid regular expressions? [closed]

Tags:

regex

Someone I know has been telling me that RegEx should be avoided, as it is heavyweight or involves heavy processing. Is this true? This made a clap in my ears, ringing my eardrums up until now.

I don't know why he told me that. Could it have been from experience or merely 3rd-hand information (you know what I mean...)?

So, stated plainly, why should I avoid regular expressions?


1 Answers

If you can easily do the same thing with common string operations, then you should avoid using a regular expression.

In most situations regular expressions are used where the same operation would require a substantial amount of common string operations, then there is of course no point in avoiding regular expressions.

like image 74
user999051 Avatar answered Sep 08 '25 10:09

user999051