How to learn Regular Expressions

(While reading these rants in comments...)

To my taste, there are no problems with regular expressions at all.

But there are problems in all sorts of escaping. Without peeking into Stack Overflow, can you tell, how to escape properly in grep/sed? If it is running in bash/zsh? In cygwin? In your favorite text editor? In bash/zsh script? How many slashes would you need for an opening bracket? For a pipe?

How many (back)slashes to escape a (back)slash? 1/2/4 (back)slashes?

Should you enclose sed command or grep pattern in (double) quotes?

You just never know. This frustrates heavily.

I don't even try to use sed or grep. Instead, I just write a small Python or Racket script to do the job. This is what I recommend. While learning Regular Expressions, just stick to your favorite programming language with RE support. Like Python or Perl. Use it for everything you need.

Then abide to a heavy burden of escaping in all sorts of exotic environments.


List of my other blog posts. My company.

Yes, I know about these lousy Disqus ads. Please use adblocker. I would consider to subscribe to 'pro' version of Disqus if the signal/noise ratio in comments would be good enough.