From: Joel VanderWerf Date: 2002-02-17T14:37:29+09:00 Subject: Re: string::literalize ? (Was, Hi this code) Jeff wrote: > 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... Use Regexp.quote (alias escape): irb(main):010:0> pattern = "what???" "what???" irb(main):011:0> "whatever, what???".sub pattern, "foo" "footever, what???" irb(main):012:0> "whatever, what???".sub Regexp.quote(pattern), "foo" "whatever, foo" -- Joel VanderWerf California PATH, UC Berkeley mailto:vjoel@path.berkeley.edu Ph. (510) 231-9446 http://www.path.berkeley.edu FAX (510) 231-9512