config/initializers/core_extensions.rb
# Normalize a string for better matching, e.g. for searches
Normalize a string for better matching, e.g. for searches
Normalize a string for better matching e . g . for searches
def normalize
    @@normalization_regex ||= /[;:,\.\(\)\[\]\!\?\*_\\\/\"\']/
    @@spaces_regex        ||= /\s+/
    @@tag_regex           ||= /<[^>]*>/
    name = self.clone
    return name.downcase.gsub(@@normalization_regex, '').gsub(@@tag_regex, '').gsub(@@spaces_regex, ' ')
    return name.downcase.gsub(@@normalization_regex, '').gsub(@@spaces_regex, ' ')
  end
def normalize @@normalization_regex ||= / [;:, \. \( \) \[ \] \! \? \* _ \\ \/ \" \' ] / @@spaces_regex ||= / \s + / @@tag_regex ||= / <[^>]*> / name = self . clone return name . downcase . gsub ( @@normalization_regex , '' ) . gsub ( @@tag_regex , '' ) . gsub ( @@spaces_regex , ' ' ) return name . downcase . gsub ( @@normalization_regex , '' ) . gsub ( @@spaces_regex , ' ' ) end
Normalize a string for better matching, e.g.
Normalize a string for better matching e . g .
# Remember, inline regexes can leak memory.  Storing as variables avoids this.