Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: non-exact regexp matches

by Anonymous Monk
on Jun 23, 2004 at 14:51 UTC ( #369052=note: print w/ replies, xml ) Need Help??


in reply to Re: non-exact regexp matches
in thread non-exact regexp matches

Thanks ! These are pretty cool (I could see come use for them in my work), but I'm looking for something which I could use a regexp:

$str = "PolarBear"; $str =~ /[Pp]olar[Bb]e[ae]r/;
if $str is "polarbear" or "polarbeer" or "Polarbear" returns 0
if $str is "PolarBeat returns 1
if $str is "PelarBeat returns 2
etc,etc.


Comment on Re^2: non-exact regexp matches
Download Code
Re^3: non-exact regexp matches
by McMahon (Chaplain) on Jun 23, 2004 at 15:02 UTC
    Ah, I see. (Also didn't realize that String::Approx doesn't use regexes)

    So this is crazy, but it just might work: stick each letter of one string into one array, then each letter of the other string into the other array. Then use List::Compare to figure out how the two strings are different.

    List::Compare is my favorite hammer these days. =)
      cool. This seems like a generalized way to go about it. Hope the performance is ok. I need to compare a 27 character reg-exp to a 1 million character string ! vince
        Reply here when you do it, if you don't mind, I'm interested. I've only ever used List::Compare against arrays with a few thousand elements. Performance was quite acceptable under those conditions. .
        You are talking about regexes, but your example shows the most trivial regex one can image, namely one that doesn't contain any characters that are special. Do you want to match any possible regex, or are you just looking for matching strings? The latter is far, far more easier than the former - and the latter doesn't need the regex engine at all.

        Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-09-18 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (104 votes), past polls