i have already working these phone.gsub(regex, "<
#{regex.match(phone)} >" ) but i think is another way to do it not?
like phone.gsub(regex,"< \1 >")
but the last instrucction does not bring the regex.match
what i want to do , is suppose you have the string "i love my dad "
the regex find dad then substitute dad <dad> , i have already solved
but i want
to know if the a fancy way to do the gsub like gsub(regex,"< \1 >")
instead of phone.gsub(regex, "< #{regex.match(phone)} >" )
p str2.gsub(/(dad)/,'<\1>') #> "I went to Bagh<dad>"
Do you also want that second match?
Harry
···
On Sat, Feb 26, 2011 at 5:33 PM, Lorenzo Brito Morales <lorenzo.brito@gmail.com> wrote:
i have already working these phone.gsub(regex, "<
#{regex.match(phone)} >" ) but i think is another way to do it not?
like phone.gsub(regex,"< \1 >")
but the last instrucction does not bring the regex.match
what i want to do , is suppose you have the string "i love my dad "
the regex find dad then substitute dad <dad> , i have already solved
but i want
to know if the a fancy way to do the gsub like gsub(regex,"< \1 >")
instead of phone.gsub(regex, "< #{regex.match(phone)} >" )
i have already working these phone.gsub(regex, "<
#{regex.match(phone)} >" ) but i think is another way to do it not?
like phone.gsub(regex,"< \1 >")
but the last instrucction does not bring the regex.match
It's to do with how double-quoted strings interpret backslashes.