Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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; }

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-02-22 14:54 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (294 votes). Check out past polls.