From: Jeff Date: 2002-02-17T13:02:00+09:00 Subject: string::literalize ? (Was, Hi this code) > > Hi, this code: > > > > text0 = "One $BLAH Three" > > text1 = "One @BLAH Three" > > text0.sub!("$BLAH", "Two") > > text1.sub!("@BLAH", "Two") > > print text0,"\n" > > print text1,"\n" > > > > produces this output: > > > > One $BLAH Three > > One Two Three ... > Yes, because the first arg to sub! is always used as a regex, even if > it's in quotes. > > "foo".sub ".", "g" > # ==> "goo" > > I've tripped up on that more times than I like to say ... Thanks; There isn't a string.deregexpify or literalize is there? I think that would be useful if not, for replacing arbitrary patterns that originate from outside a program. If not, maybe I'll try... JDonner