Mr. Shawn H. Corey wrote:
On Fri, 2006-30-06 at 23:04 +0200, Filip Jursik wrote:
Hi,
this
$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"
What am I doing wrong? I've expected the .*? to limit the wildcard only to the
string " second ".
You mean something like this?
#!/usr/bin/perl
use strict;
use warnings;
my $text = "first first second third";
$text =~ /(?:first.*)(first.*third)/;
print $1, "\n";
Well, I thought, that when I write:
1) /A(.*)B/, $1 will hold the longest string enclosed by A and B
2) /A(.*?)B/, $1 will hold the shortest string enclosed by A and B
Does it work like this or the "?" after the ".*" has a different meaning than
changing the match from the longest to the shortest possible one?
Thanx,
F.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>