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

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

Re: regex replace


From: Malte Spiess
Subject: Re: regex replace
Date: Tue, 12 Dec 2006 10:44:32 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Gary Wessle <phddas@yahoo.com> writes:

> Malte Spiess <i1tnews@arcor.de> writes:
>
>> Gary Wessle <phddas@yahoo.com> writes:
>> 
>> > "rgb" <rbielaws@i1.net> writes:
>> >
>> >> Gary Wessle wrote:
>> >> > Hi
>> >> >
>> >> > I need to remove the "//" from the beginning of all the lines in my
>> >> > c++ code which contain the string 'n', including the single comma.
>> >> > e.g, un-comment all of those lines that qualify. and then also to
>> >> > place "//" not including the double quotes at the beginning of all
>> >> > lines containing the 'f' string.
>> >> >
>> >> > this is a bit too much for me to come up with.
>> >> >
>> >> > thanks
>> >> 
>> >> C-M-% ^\(//\)\(.*'n',\)<RET>\2<RET>
>> >> 
>> >> C-M-% ^.*'f'<RET>//\0<RET>
>> >
>> >     //    if( some switch->fd ) p_acc->sbs(a_f, morearg, somemore, 'n', 
>> > 0); // no action taken
>> >
>> > the first command you posted will not work on the above, even after I
>> > modified it to take the spaces at the start like this.
>> > C-M-% ^ *\(//\)\(.*'n',\)<RET>\2<RET>
>> 
>> Hm, strange, works fine here!
>> 
>> Could you maybe tell us what was your output? 
>  
> something like 0 replaced.

Okay, that is very helpful to find the problem.
It would be useful if you left out part of the search string to see if
Emacs fails to find that or the other part.
Try e. g.:
C-M-% ^ *\(//\)<RET>whatever<RET>
or
C-M-% \(.*'n',\)<RET>foobar<RET>

>>Are you sure you really
>> did C-M-% and not M-% ? What other line did it work with?
>> 
>
> C-M-% does not work here.
> GNU Emacs 21.4.1 (i386-redhat-linux-gnu, X toolkit, Xaw3d scroll bars)
> of 2006-03-07 on hs20-bc1-6.build.redhat.com
>
> so I did M-x query-replace-regex 
> I am still don't know why it did not fire.

Okay, that is fine, too.

Greetings

Malte


reply via email to

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