Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: help with minimal matches

by Anonymous Monk
on Mar 18, 2001 at 13:29 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found