Reputation: 1257
Can someone please explain why this Emacs regexp
find_class \(\w+|([^)]+)\) \(\w+|([^)]+)\)
does not match in any of these lines?
let _, scn, _ = find_class (obj :: cs) c in scn
aux (find_class (obj :: cs) scn) (cn :: desc)
let _, scn, ms = find_class c cs in
It seems pretty simple: I'm looking for an invocation of the function where the arguments can appear as single words, or parenthesized arbirary strings. When I plug an equivalent expression (find_class (\w+|\([^)]+\)) (\w+|\([^)]+\))
) into Ruby it does what I want, but not here. Am I missing something?
I'm finding Emacs' regexps really cumbersome for practical use, to the point where I'm reconsidering my choice of editor. If there is a reasonable way to improve this (i.e. more concise syntax, more character classes), I am dying to hear it, but I haven't found anything yet.
Upvotes: 3
Views: 422
Reputation: 17422
Re: cumbersome, it helps to have a look at the documentation of Emacs' regexps:
http://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-of-Regexps.html
Section 3, "Regexp Backslash", contains the answer to your question which has been pointed out by nhahtdh already. Don't forget that Emacs' regular expression syntax predates the POSIX standard.
Upvotes: 3
Reputation: 56809
I think you need \|
in emacs regex to achieve same effect as |
in Ruby.
Upvotes: 3