On Dec 16, 2007 2:21 PM, namotco <[EMAIL PROTECTED]> wrote: > Let's say I want to search some text for "abc123". However, we know > people can make typos and so they could have entered avc123 or abc223 > or sbc123 or bc123 many other combinations... > So I want to search for those possibilities as well. So how would I > go about creating the proper regex? > > Thanks! > How do you define a typo? How do you know whether it's a typo, or a different string? Do you know, for instance, that only 'abc\d\d\d' is valid, and 'avc\d\d\d' is never valid? If so, you could do something like:
if (/^abc\d\d\d$/ or s/^a.c(\d\d\d)$/abc$1/) { # match! } else { #no match! } If you can't predict the input, though, you'll need some heavy duty algorithmic logic. Take a look through CPAN and see if there isn't something that meets your needs. String::Approx and String::KeyboardDistance might be places to start. There are also a number of things in the Text::* tree. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!