Question: I have a table of strings in my database. I select one of them, *A*.

How I can search the rest of the table to find the string most similar to *A*?

Answer: 
I think you are looking for the levenstein distance.
The levenstein distance between 2 string, is how much adding/deleting/modifying char is needed to make the string equals.

[Here's an implementation in Ruby](https://github.com/threedaymonk/text)
Here is a simple implementation of the Levenshtein Distance Algorithm in Ruby : 

```
def levenshtein(a, b)
  case
    when a.empty?: b.length
    when b.empty?: a.length
    else [(a[0] == b[0] ? 0 : 1) + levenshtein(a[1..-1], b[1..-1]),
          1 + levenshtein(a[1..-1], b),
          1 + levenshtein(a, b[1..-1])].min
  end
end

```

The Levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.