Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: help with minimal matches

by Anonymous Monk
on Mar 18, 2001 at 13:29 UTC ( #65253=note: print w/replies, xml ) Need Help??


in reply to help with minimal matches

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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://65253]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2021-11-28 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?