Next: , Previous: , Up: Common requests   [Contents][Index]

5.36 How do I use regexps (regular expressions) in Emacs?

See Regexp Backslash in The GNU Emacs Manual.

The or operator is ‘\|’, not ‘|’, and the grouping operators are ‘\(’ and ‘\)’. Also, the string syntax for a backslash is ‘\\’. To specify a regular expression like ‘xxx\(foo\|bar\)’ in a Lisp string, use ‘xxx\\(foo\\|bar\\)’.

Note the doubled backslashes!