lib/ruby_classes/strings.rb
def autoregex(anything)
  deb "Autoregex() supercool! With a #{blue anything.class}"
  case anything.class.to_s
    when 'String' 
      if anything.match(/^\/.*\/$/) # '/asd/' is probably an error! The regex builder trails with '/' automatically
        fatal 23,"Attention, the regex is a string with trailing '/', are you really SURE this is what you want?!?"
      end
      return  Regexp.new(anything)
    when 'Regexp'
      return anything # already ok
    when 'Array'
      return Regexp.new(anything.join('|'))
    else
      msg = "Unknown class for autoregexing: #{red anything.class}"
      $stderr.puts( msg )
      raise( msg )
  end
  return nil
end
def autoregex(anything)
  deb "Autoregex() supercool! With a #{blue anything.class}"
  case anything.class.to_s
    when 'String' 
      if anything.match(/^\/.*\/$/) # '/asd/' is probably an error! The regex builder trails with '/' automatically
        fatal 23,"Attention, the regex is a string with trailing '/', are you really SURE this is what you want?!?"
      end
      return  Regexp.new(anything)
    when 'Regexp'
      return anything # already ok
    when 'Array'
      return Regexp.new(anything.join('|'))
    else
      msg = "Unknown class for autoregexing: #{red anything.class}"
      $stderr.puts( msg )
      raise( msg )
  end
  return nil
end
supports: strings, arrays and regexes :)
 @returns a Regexp