Presumabley you have an expression something like this:
$text =~ s/print.*a_string//g;
The problem is that by default the .* is greedy. That is to say, it takes up as much of the string as it can. What you need to to change your code to
$text =~ s/print.*?a_string//g;
which will make the .* non-greedy. This is covered in more detail in perldoc perlre.
--
<http://www.dave.org.uk>
European Perl Conference - Sept 22/24 2000
<http://www.yapc.org/Europe/>
In reply to Re: A Reg Exp Question
by davorg
in thread A Reg Exp Question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |