News for hackers. Stuff that matters.
Re:Is it a must for every programmer to learn regular expres... by arnsholt on Thursday August 16, 2012 @04:17AM (#4390391)
IMO, the main problem is that the syntax is too terse. The syntax is taken wholesale from the algebraic notation used in mathematics and dropped in unmodified. Essentially, regex code ('cause regexes really are code) is not skimmable.

The greatest syntactical atrocity in regexes is that they don't have the `x` modifier (in Perl parlance) on by default. This means that you can't use whitespace to chunk code into meaningful bits, nor can you comment it to easily document what does what or explain a particularly hairy section to handle some weird edge case. This means that regexes degenerate a lot faster than ordinary code in terms of readability.

Edit: Misplaced close paren.

Re:Is it a must for every programmer to learn regular expres... by yen223 on Thursday August 16, 2012 @04:37AM (#4390441)
"Easy to write, hard to read". Perl's influence on Regex shows. Which is fine in most cases.

I always wonder what regexes would look like if they were derived from Python instead.

Re:Is it a must for every programmer to learn regular expres... by arnsholt on Thursday August 16, 2012 @04:46AM (#4390468)
Actually, regex syntax isn't primarily a Perl invention. Regexes as software tools go back to early Unix text processing tools (ed and grep, according to Wikipedia), and Perl took the syntax from those tools.

It is true that Perl reformed the syntax in important ways (to the better, if you ask me), and later on extended it a lot, but it's certainly not a Perl invention.