thats really handy especially for re-doing all the flag bits at once, is there a way to make it distinguish between, say ch->act and ch->comm so it only changes the act's and not the comm's?

From: "Richard Lindsey" <[EMAIL PROTECTED]>
To: "Chad Simmons" <[EMAIL PROTECTED]>,"Michael Barton" <[EMAIL PROTECTED]>
CC: <rom@rom.org>
Subject: RE: regular expression search and replace
Date: Tue, 6 Sep 2005 16:43:23 -0500

And I'd just like to add my \s* into that regex, because a lot of people
put a space between the opening parentheses and their text, like
REMOVE_BIT( ch->act, PLR_WHATEVER ), and so with the regex below, you
run the risk of winding up with remove_bit(& ch->act, PLR_WHATEVER ),
but if you use:

perl -pe 's/REMOVE_BIT\(\s*/remove_bit(&/g' -i.BAK *.c

then that should compensate for any amount of whitespace... also, should
the ampersand be escaped? I know it had to be in vi in order to work
correctly, and regexes generally use that as an end-of-string marker
similar to the beginning-of-string ^ marker... Just 2 additional cents
:D

Richard Lindsey.

-----Original Message-----
From: Chad Simmons [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 4:41 PM
To: Michael Barton
Cc: rom@rom.org
Subject: Re: regular expression search and replace

--- Michael Barton <[EMAIL PROTECTED]> wrote:

> [red ~/test/]$ perl -pe 's/REMOVE_BIT\(/remove_bit(&/g' -i *.c
>
> ...I'd make a backup first.
>
> Oh, and real men write their code with echo.  Or maybe cat.
> echo '#include <stdio.h>' >> test.c
>
> --Palrich.


Actually if you do

perl -pe 's/REMOVE_BIT\(/remove_bit(&/g' -i.BAK *.c

it will automatically backup the files, appending a .BAK extension.

-----BEGIN GEEK CODE BLOCK-----
Version 3.12
GCS/IT/L/S/O d-(+) s++: a-(?) C++++$ UBLS++++$
P+++(--)$ L++++$ E--- W+$ N !o K? w(---) !O
M- !V PS+ PE(-) Y+ PGP->+ t+ 5 X++ R(+) tv+@
b+(++) !DI+++ D G(-) e>+++ h---() r+++ y+++(++)
------END GEEK CODE BLOCK------




______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/
--
ROM mailing list
ROM@rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
ROM@rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to