From: Nuralanur@... Date: 2005-09-27T07:46:05+09:00 Subject: In search of a kind of converse to sub/gsub -------------------------------1127774756 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Dear all, while reading the thread about ggsub, I recalled a problem I have tried to code but stopped for lack of time. Now, if you can't do it yourself, why not let others work for you ;-) ? When correcting a text for typos, one can minimize the Levenstein distance (number of character changes from one string to another) of the mis-spelled word to a list of correctly-spelled words. However, many words are short, and there are a lot of "correct", English words you can produce by, say, changing three letters in a three-letter word. Yet typos are much more specific - there are essentially inversions 'ab' ->'ba' or misspellings coming from hitting nearby keys on the keyboard. Now I am too lazy to identify all these possibilities and I am searching for some method of the form class String def find_what_to_replace(other) ... return replace_what_substring,replace_by end end such that for replace_what_substring,replace_it_by =string1.find_what_to_replace(string2) the statement string2 == string1.gsub(replace_what_substring,replace_it_by) holds true . Has anybody done that already? Best regards, Axel -------------------------------1127774756--