I’m looking either for routine or way to look for error tolerating string comparison.
Let’s say, we have test string Čakánka – yes, it contains CE characters.
Now, I want to accept any of following strings as OK:
- cakanka
- cákanká
- ČaKaNKA
- CAKANKA
- CAAKNKA
- CKAANKA
- cakakNa
The problem is, that I often switch letters in word, and I want to minimize user’s frustration with not being able (i.e. you’re in rush) to write one word right.
So, I know how to make ci comparison (just make it lowercase :]), I can delete CE characters, I just can’t wrap my head around tolerating few switched characters.
Also, you often put one character not only in wrong place (character=>cahracter), but sometimes shift it by multiple places (character=>carahcter), just because one finger was lazy during writing.
Thank you :]
Not sure (especially about the accents / special characters stuff, which you might have to deal with first), but for characters that are in the wrong place or missing, the
levenshteinfunction, that calculates Levenshtein distance between two strings, might help you (quoting) :Other possibly useful functions could be
soundex,similar_text, ormetaphone.And some of the user notes on the manual pages of those functions, especially the manual page of
levenshteinmight bring you some useful stuff too 😉