Reputation: 511
I understand, in the configuration files, it's always \\( to escape special char like (, however, when we do re-search-replace, it should be \( or \\(?
Upvotes: 2
Views: 31
Reputation: 44043
For M-x re-search-*
and M-x regexp-replace
, use \(
. Generally, do so whenever you're entering a regular expression at a prompt.1
The reason you have to use \\(
in configuration files (or any elisp) is that there the regexes will be encoded as strings, and in string literals backslashes have to be escaped to be distinguishable from other escape sequences (i.e., "\\n"
is a backslash followed by an n
, whereas "\n"
is a newline).
1 Thanks to @phils for pointing out that this should be mentioned explicitly.
Upvotes: 2