One of my collaborators has written a long rtf document that goes like this.
a paragraph of text
(1) some text
another paragraph or two of text
(2) some text
another paragraph or two of text
And so on. I've opened the file in emacs and I was trying to run replace-regexp
to turn the parenthesized numbers into \exx{
, where \exx{
is a newcommand I have defined in the preamble and will take turn of sequential numbering. However, if I type
M-x replace-regexp ^([0-9]\{1,2\}) RET \exx\{ RET
Then I get the following error message
Invalid use of `\' in replacement text
I have tried using this alternative expression
M-x replace-regexp ^([0-9]\{1,2\}) RET \\\\exx\\{ RET
But this simply replaces (1)
and subsequent numbers with \\exx\{
, which is not what I want. Every other combination of backslashes that I have tried returns the Invalid use of \ in replacement text
error.
I know I can use sed
to get regexp replacement I want, but that is not the issue. I'm asking this question here because I want to understand how to do this particular type of regexp replacement internally to emacs.
\\exx\\{
(1)
with\exx\{
, which is not what I want. I want the opening curly bracket without a preceding backslash.\\exx{
.