perl search in greedy mode:
my $string = 'bcdabdcbabcd';
$string =~ m/^(.*)ab/;
print "$1\n"; # prints: bcdabdcb
perl search in non-greedy mode:
my $string = 'bcdabdcbabcd';$string =~ m/^(.*?)ab/;print "$1\n"; # prints: bcd
In this case the .*? portion attempts to match the least amount of data
No comments:
Post a Comment