seebs
6/11/2007 2:13:00 PM
In message <b4c60e38ff75eea451c544b6d2d7a2a2@ruby-forum.com>, Li Chen writes:
>Thanks, but the replacement still doesn't work.
>It is my understanding that Regexp#escape method should do the magic
>work for me.
Your understanding makes no sense.
When you put a backslash in a string, it is eaten up by the interpreter
BEFORE ANY METHODS ARE ACTUALLY CALLED. Regexp#escape gets the string
AFTER backslashes have been eaten.
So there's nothing there for it to escape. The escape method isn't
magic; it can't tell how your source is laid out, only what actual string
it is given.
-s