my $str = "abc def ghi abc 123 junk"; my $short; while ($str =~ /abc.*?123/g) { $short = $& if ! defined $short or length($&) < length($short); pos($str) = $-[0]+1; } print "$short\n";
In reply to Re: Getting the shortest match?
by runrig
in thread Getting the shortest match?
by saintbrie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |