Tom Lieber on 17 Jun 2006 00:10:08 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] Ruby gsub question


On 6/16/06, Chris <theechief@comcast.net> wrote:
Using gsub you get two backslashes...

For just the (
"(hello)".gsub(/\(/,'\\\(')

You use single quotes for the second parameter, so it doesn't do any substitutions. Thus, you can just write:

"(hello)".gsub(/\(/,'\(')

Note that if you just type that into irb, it will show you two slashes
because it outputs with the escapes. This will show you what it really
is:

puts "(hello)".gsub(/\(/,'\(')

Chris Lorenzo

Sincerely,

Tom Lieber
http://AllTom.com/
http://GadgetLife.org/
_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk