It seems as if the OP is asking for a simple name completer. For example, I would use it like find("trey"); instead of find("Treynolds416");
The title is a bit misleading, but you would use the above code.
If you actually wanted to do something that found the closest string, you would use a different method than posted above. I like to think of it as sort a spell-check idea. One (or more letters, depending on how well you want this to work), would be replaced and cycled through the alphabet until a real word is found.
For example, I could type getClosestStr("difine"); and get "define" back. The script would run through lots of combinations:
"aifine"
"bifine"
"cifine"
"eifine"
"aifine"
...
...
...
"dcfine"
"ddfine"
"define" STOP
You could also make it 'smarter' in that it doesn't try consonants in certain points in the word, to save some computing power.