[Chicago-talk] Regex question

Andy_Bach at wiwb.uscourts.gov Andy_Bach at wiwb.uscourts.gov
Thu Apr 28 10:05:48 PDT 2011

> You're actually going to want to use it with a ? in there:


> Otherwise it's greedy and will replace everything from Hello through the 
last comma 

Maybe a typo but:

the "?" modifies the '*', in the original it was saying "zero or one 
commas" - and you'd need to replace the "Hello " text too.  the "/g" would 
mean there's possibly more than one "Hello ...." chunk in your letter?

Another good idiom is to use the negative char class for the marker 
s/Hello\s+[^,]+,/Hello $ES,/;

That is - "one or more of anything besides a comma" 

Andy Bach
Systems Mangler
Internet: andy_bach at wiwb.uscourts.gov
Voice: (608) 261-5738; 
Cell: (608) 658-1890

"All that I care to know is that a man is a human being
--that is enough for me; he can't be any worse."
Mark Twain (1835-1910) 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110428/97abe046/attachment.html>

More information about the Chicago-talk mailing list