Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: search of a string in another string with 1 wildcard

by choroba (Chancellor)
on Jul 29, 2014 at 09:30 UTC ( #1095478=note: print w/replies, xml ) Need Help??


in reply to Re: search of a string in another string with 1 wildcard
in thread search of a string in another string with 1 wildcard

This seems similar to Multiple Approximate Pattern Matching Problem. Here's my solution:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; chomp(my $text = <>); my @patterns = split ' ', <>; my $threshold = 0 + <>; my @ctext = split //, $text; my @results; for my $pattern (@patterns) { my @cpat = split //, $pattern; POSITION: for my $pos (0 .. @ctext - @cpat) { my $mismatches = 0; for my $i (0 .. @cpat - 1) { if ($cpat[$i] ne $ctext[$pos + $i]) { next POSITION if ++$mismatches > $threshold; } } push @results, $pos; } }; say join ' ', sort { $a <=> $b } @results;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1095478]
help
Chatterbox?
[Lady_Aleena]: shmem, sorry I was outside for a moment moving my car out of hubby's way.
[Lady_Aleena]: shmem, there is ONE song which throws a wrench in the works for both MP3::Info and MP3::Tag.
[shmem]: Lady_Aleena: fix it, or delete it ;-)
[Lady_Aleena]: shmem, I'm not sure how.
[shmem]: well, deleting is done with 'rm' :-P

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2017-04-23 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.