This is because it sounds like you'll want to match even:
Which a normal regexp will be unable to follow easily.print "Bob was $frank \"yes!\" around"."No Way!", $foo, "\n"; #or print "joe" if $bar;
That said, if this is a one-time job with certain rules you can rely on, there are ways to do what you want. For example, if every statement ends with a semi-colon, and the word "print" is never used in strings in the Perl script, you could try matching
But be aware that even something as simple as:/print[^;]*;/
Would mess that up. If you have a situation with many situations, use a real Parser.if($foo){ print "Bar" } # or $foo= "Ask frank to print the report";
Note also that you might mess up the logic of a program. See:
If your program relies on &func($bar) being called several times, you would have eliminated the entire statement if using the simple regexp; Thanks to lhoward for introducing me to Parse::RecDescentprint "Foo\n" while &func($bar);
In reply to Re: A Reg Exp Question
by swiftone
in thread A Reg Exp Question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |