Rob Dixon schreef:
> Filip Jursik:
>> $text = "first first second third";
>> $text =~ /(first.*?third)/;
>> print $1;
>> gives me
>> "first first second third"
>> as a result instead of expected
>> "first second third"
>
> The regex engine will match one element at a time. Yours matches
> 'first', then as few characters as possible, then 'third'. Only if
> the entire match fails will it try finding 'first' in a different
> place. If you want your expression to match at the last 'first' then
> just chew up as many characters as possible before testing for it:
>
> my $text = "first first second third";
> $text =~ /.*(first.*?third)/;
> print $1;
Alternative:
/.*(first.*third)/
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>