Jeff Schwab
5/10/2006 5:42:00 PM
Hoppy wrote:
> str = "$$$$$$$$"
> str.gsub(/([$(&])/, '/\1') # => "/$/$/$/$/$/$/$/$"
>
> Now how do I return this instead: "\$\$\$\$\$\$\$\$"?
> # each matched character preceded by a single backslash
irb(main):032:0> puts str.gsub(/([$(&])/, '\\\\\1')
\$\$\$\$\$\$\$\$
=> nil
A bitch, no?