Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: searching for a string w/ a * in any single position?

by blokhead (Monsignor)
on Oct 05, 2007 at 23:06 UTC ( #643000=note: print w/replies, xml ) Need Help??


in reply to Re^2: searching for a string w/ a * in any single position?
in thread searching for a string w/ a * in any single position?

Generalizing this approach for Hamming distance > 1, using the combinations iterator from Iterating over combinations:
sub gen_regex { my ($target, $n) = @_; my @chars = split //, $target; my $ra = Regexp::Assemble->new(); my $iter = combinations( $n => [ 0 .. $#chars ] ); while (my @c = $iter->()) { local @_ = @chars; $_[$_] = '.' for @c; $ra->add( join '', @_ ); } $ra->re(); }

blokhead

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://643000]
help
Chatterbox?
[Discipulus]: Anyway many years passed, we had Perl 3 iirc.. ;=)
[1nickt]: erix looking ... which one?
[1nickt]: Ah hm, the article sction links don;t match the sections. Lowerdown there is info and a map

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2017-11-21 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (299 votes). Check out past polls.

    Notices?