I need to convert back and forth between the string representation of a Regexp and the Regexp itself.
Something like this:
> Regexp.new "\bword\b|other
=> /\bword\b|other/
However, doing so results in /\x08word\x08|other/
Is there some way to accomplish this?
\bto match in the regex?\bto match a word boundary. e.g. "sword" would not match/\bword\b/but "word" would.Regexp.new "\\bword\\b|other" #=> /\bword\b|other/.to_s/sourceto get its string representation.