help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replace-regexp not working?


From: Sanford Selznick
Subject: Re: replace-regexp not working?
Date: Mon, 21 Jul 2003 19:58:29 -0700
User-agent: MT-NewsWatcher/3.3b1 (PPC Mac OS X)

In article <?fnord?uy8yrct7x.fsf@ID-97657.usr.dfncis.de>,
 lawrence mitchell <wence@gmx.li> wrote:

> Sanford Selznick wrote:
> 
> > I have a file open (input.txt) and I'm trying to replace all "x" or "y"
> > characters with a string, say "12".
> 
> > So I M-x replace-regexp RET (x|y) RET 12 RET
> 
> > And nothing happens.  The cursor is at the beginning of the buffer.
> 
> > What am I doing wrong?
> 
> Emacs' regex's require you to quote some special characters.  So,
> characters like (, |, and ) are assumed non-special, unless you
> quote them.
> 
> In your case, you would do:
> 
> M-x replace-regexp RET \(x\|y\) RET 12 RET
> 
> See the Emacs info node (info "(emacs)Regexps") for details.

Ugh.  

Thank you all for your help.  And just for the archives, if you put this 
on the command-line for batch processing, you have to escape your 
escapes.  As in:

emacs --batch "input.txt" --eval '(replace-regexp "\\(x\\|y\\)" "12")' 
-f save-buffer 

Are we having fun yet?  ;-)

Thank you all again.

Best,
  Sanford


reply via email to

[Prev in Thread] Current Thread [Next in Thread]