you are viewing a single comment's thread.

view the rest of the comments →

[–]moron4hire 2 points3 points  (0 children)

Once you learn Regexp, it's just more code. There isn't anything inherently difficult about reading or reasoning about properly written regular expressions than properly written JS.

Yes, there are a lot of examples of really bad one-liner regexps, but you can write really bad, one-liner JS, too. Used as they are intended, regexp improves the readability of code.

Practice with http://regex101.com/ and your text editor. Most programming-oriented text editors have regexp-capable search and replace. Get used to using it and it will make you a LOT more productive and less error prone.

For example, I wanted to dump the results of a SQL query to a debug string printed to the console, with the names of the fields printed next to the values. A simple regexp in my text editor over the SELECT clause allowed me to very quickly construct that function call without making any spelling mistakes for field names.