[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: why gsub! doesn't work in my script

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