title: How can I do fuzzy substring matching in Ruby?
body: <p>I found lots of links about fuzzy matching, comparing one string to another and seeing which gets the highest similarity score. </p>
  
  <p>I have one very long string, which is a document, and a substring. The substring came from the original document, but has been converted several times, so weird artifacts might have been introduced, such as a space here, a dash there. The substring will match a section of the text in the original document 99% or more. I am not matching to see from which document this string is, I am trying to find the index in the document where the string starts.</p>
  
  <p>If the string was identical because no random error was introduced, I would use <code>document.index(substring)</code>, however this fails if there is even one character difference. </p>
  
  <p>I thought the difference would be accounted for by removing all characters except a-z in both the string and the substring, compare, and then use the index I generated when compressing the string to translate the index in the compressed string to the index in the real document. This worked well where the difference was whitespace and punctuation, but as soon as one letter is different it failed.</p>
  
  <p>The document is typically a few pages to a hundred pages, and the substring from a few sentences to a few pages.</p>