[tpm] Regex question

Indy Singh indy at indigostar.com
Tue Nov 6 10:39:39 PST 2007


Hello all,

I have some multiline data as shown below.  I want to remove all 
occurances of 'foo.*?' that are at the beginning of a line.  How can I 
do that witha regex.  I can do it with a while loop, but is a there a 
more elegent way with a single regex?  Perhaps using some look ahead or 
look behind assertion.


$x='foo one
foo two
other foo three
more stuff
';
print "x=$x";
while ($x =~ s//(^|$)foo.*?\n//gs) {1;}
print "x=$x";







More information about the toronto-pm mailing list