From: Luis Parravicini Date: 2009-09-30T06:17:13+09:00 Subject: Re: Match a long string in Ruby despite a few typing errors On Tue, Sep 29, 2009 at 5:23 PM, Ehsanul Hoque wrote: > > I'd like to match a string to another, and recognize the match even if there are a few typing errors. These errors could include omission of a letter/space/punctuation mark, an extra letter or a mistyped letter. I don't require it to detect multiple errors in a row, or in a single word. The string would be comparable to the length of this paragraph, a little shorter, in case that matters > >  I could come up with some basic implementation for this, but it seems like a little too much to do for something like this. I was wondering if there was a simple way to do this, a gem perhaps? > You could use the Levenshtein distance [1] to check how different is a string to another. The "Text" [2] gem seems to do that, haven't used it though. [1] http://en.wikipedia.org/wiki/Levenshtein_distance [2] http://raa.ruby-lang.org/project/levenshtein/ -- Luis Parravicini http://ktulu.com.ar/blog/