RE: regular expression search and replace

"Tristan M" <[email protected]> Tue, 06 Sep 2005 22:22:04 +0000
Newsgroups gmane.games.devel.mud.rom
Message-ID <[email protected]>
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: <[email protected]>
>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: [email protected]
>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
>[email protected]
>Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>--
>ROM mailing list
>[email protected]
>Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom


-- 
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom