Emacs Elements on Emacs Regular Expressions

Over at Emacs Elements there’s a nice video that explores Emacs regular expressions. One the one hand, virtually everyone hates Emacs regular expressions and wishes that Emacs used Perl compatible regexes instead. On the other hand, a case can be made that Emacs regexes are optimized for the typical Emacs use cases. In either case, it’s an old war and a boring one. One can arrange to use Perl regexes but most of us just accept the pain and use the default.

Still, even for those of us who have accepted the inevitable, the rules governing Emacs regexes can seem arcane and sometimes needlessly complex. Why, for example, do we have to use [0-9] instead of \d to specify a digit?

Emacs Elements’ latest video is a nice précis of the rules and conventions for using regexes in Emacs. The three parts that I really liked were

  1. Listing the exact characters that need to be escaped
  2. A good explanation of how to search using syntax classes
  3. An explanation of the non-greedy operators

but the video covered most aspects Emacs regular expressions and is a good explanation or refresher for those who have occasion to use them. The video is 22 and a quarter minutes so you’ll probably have to schedule some time but it’s definitely worth watching.

This entry was posted in General and tagged . Bookmark the permalink.