I
Intransition
Hi--
I want to translate a string into a regular expression, but I want to
"un-escape" portions as raw regexp. For example:
"here is a setting 'a' equal to ((\d+))"
So I want to Regexp.escape the string, before I pass it to Regexp.new,
but I want what's in the (( )) to stay exactly the same with the
double-parens removed.
I know that has to be a fairly concise way to do this, but all I've
come up with is some very ugly brute force code that iterates back and
forth using index '((' and index '))'.
Any suggestions?
I want to translate a string into a regular expression, but I want to
"un-escape" portions as raw regexp. For example:
"here is a setting 'a' equal to ((\d+))"
So I want to Regexp.escape the string, before I pass it to Regexp.new,
but I want what's in the (( )) to stay exactly the same with the
double-parens removed.
I know that has to be a fairly concise way to do this, but all I've
come up with is some very ugly brute force code that iterates back and
forth using index '((' and index '))'.
Any suggestions?