Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2016-04-28 22:56 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (437 votes). Check out past polls.