Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: non-exact regexp matches

by bageler (Hermit)
on Jun 23, 2004 at 18:57 UTC ( #369138=note: print w/ replies, xml ) Need Help??


in reply to non-exact regexp matches

why does it need to be in a regexp? Sounds like you just want a string comparator, unless you have more complex patterns in mind.

$str = 'PolarBear'; my @str = split//,$str; my @pats = qw(polarbear Polerbear Polarbeer); for (@pats) { my @mat = mismatches($_,$str); print "Mismatches for $_ vs $str: @mat\n"; } sub mismatches { my ($p1,$p2) = @_; my @foo = split//,$p1; my @str = split//,$p2; my @pos; if ($#foo > $#str) { for (0 .. $#foo) { push @pos, $_ if $foo[$_] ne $str[$_]; } } else { for (0 .. $#str) { push @pos, $_ if $foo[$_] ne $str[$_]; } } return @pos; }


Comment on Re: non-exact regexp matches
Download Code
Re^2: non-exact regexp matches
by vinforget (Beadle) on Jun 23, 2004 at 19:05 UTC
    The problem is that I have a query string that is rather short, and a subject string that is long (~1 million chars) that can contain multiple nested matches.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-09-21 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (173 votes), past polls