Axel asked for a method find_what_to_replace
> ... 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?

Does Diff::LCS do what you want? It returns the differences between strings.
(You can get it from http://rubyforge.org/frs/?group_id=84 or via rubygems)

Cheers,
Dave