From: Nikodemus Siivola Date: 2002-05-16T08:35:34+09:00 Subject: Re: How to Convert Regex Back to String in Exact Match? On Thu, 16 May 2002, William Djaja Tjokroaminata wrote: > the special case such as above (we know how reg was created from str), is > there an easy way to convert reg to str? Untested && unsporting && wasteful code follows, taking lead from Nobu's suggestion to save the string -- let the class do it for you... class Regexp alias old_escape escape def Regexp.escape(string) escaped = old_escape(string) @@unescape = {} unless defined?(@@unescape) @@unescape[escaped]=string return escaped end def Regexp.unescape(regexp) @@unescape[regexp] || raise end end ;) -- Nikodemus