Tuesday, 21 April 2015

Regular Expression: Non-greedy Matching

Cited from Regular Expression Tutorial Part 5: Greedy and Non-Greedy Quantification


To make the quantifier non-greedy you simply follow it with a '?'

symbol:

my $string = 'bcdabdcbabcd';

$string =~ m/^(.*?)ab/;

No comments:

Post a Comment