You can stick a greedy quantifier before your non-greedy match. That way the greedy quantifier will eat up as much as it can while the non-greedy part will still match. You seem to call "lazy" what the Perl documentation calls "non-greedy" in perlre.
#!/usr/bin/perl -w use strict; my $string = "The quick brown fox jumps over the lazy dog"; $string =~ /.*(the .*? dog)/i; print "Match: '", $1, "'"; __END__ Match: 'the lazy dog'
In reply to Re: Pattern matching: Lazy vs. greedy
by Corion
in thread Pattern matching: Lazy vs. greedy
by false_friend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |