Skip to content

Instantly share code, notes, and snippets.

@vinbarnes
Created May 6, 2009 17:51
Show Gist options
  • Save vinbarnes/107635 to your computer and use it in GitHub Desktop.
Save vinbarnes/107635 to your computer and use it in GitHub Desktop.
>> Regexp.escape('asdf')
=> "asdf"
>> Regexp.escape('asdf*')
=> "asdf\\*"
>> Regexp.escape(/asdf*/)
TypeError: can't convert Regexp into String
from (irb):3:in `escape'
from (irb):3
from :0
>> Regexp.escape(/asdf/)
TypeError: can't convert Regexp into String
from (irb):4:in `escape'
from (irb):4
from :0
>> Regexp.escape(/asdf/.to_s)
=> "\\(\\?\\-mix:asdf\\)"
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment