my $search = 'is today saturd or sunday?'; my $record = 'saturday'; my $pattern; my @chars; my @patterns; my $len = 4; @chars = split(//, $search); for(my $i = 0; $i <= length($search) - $len; $i++) { push(@patterns, quotemeta(join('', @chars[$i .. $i + $len - 1]))); } $pattern = '(?:'.join('|', @patterns).')'; if($record =~ /$pattern/) { print "Match with pattern $pattern\n"; }
In reply to Re: help with minimal matches
by Anonymous Monk
in thread help with minimal matches
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |