Finding data which, when tweaked, matches.

The SQL regex stuff others have posted is one way to do it, but note
that scanning a table like that is inherently going to be slow, and
will get slower as the table gets bigger.

If you're doing this operation a lot, it might be valuable to pre-
compute the number strings for the identifier field, like this:

class Patient
  # add a new field, identifier_numbers perhaps

  before_save :sanitize_indentifier

  def sanitize_identifier
    self.identifier_numbers = identifier.gsub(/[^0-9]/,"") if
identifier
  end
end

Then you can just search against identifier_numbers.

--Matt Jones