Regex to match similar strings


Im writing some validation code the basically make sure a users login is
not too similar to their password. I was thinking a regular expression
to match similarities and if they are alike then make the user change
their password.

This doesnt have to be bullet proof just enough to really say if
someones username is bobbysmith then their password cant be bobbysmith7
or bobbysmi7

Anyone got a solution, is it possible to do this with a regular
expression or will it be some ruby code ina loop…


Here are a couple ruby libraries that may help you out. I found this a
while back on a ruby sitewhen I was looking to compare strings for
duplicates when cleansing data.
The first is distance between strings. (I prefer this one)
The second is the traditional soundex Remove vowels take the first
letter run a calc on the rest.Its not very reliable but may help.
The third is like soundex but larger strings.
Here is the link to the original

Thanks Chris, exactly what i needed. Installed the amatch gem and have
it running now,


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs