ts wrote:
>>>>>> "W" == Wesley J Landaker <wjl / icecavern.net> writes:
> 
>W> Apparently, Andreas Schwarz recently wrote:
> 
>>> irb(main):004:0> "foo.bar".gsub( /#{Regexp.escape(".")}/,
>                               ^^^^
> 
>W> irb(main):002:0> s['.'] = '.\1'
>                      ^^^^^
> 
>  You don't do the same : he want to use #gsub not #sub

Exactly. The only solutions I can think of:
1) use regex_escape() for the string that should be replaced, and
   remove backreferences in the replacement string manually
2) do it char by char, like in C.

1) is ugly, 2) is slow and even uglier.


-- 
AVR-Tutorial, er 350 Links
Forum f AVRGCC und MSPGCC
-> http://www.mikrocontroller.net