From: "Mauricio Fernández" Date: 2005-08-02T02:02:54+09:00 Subject: Re: Redefining Regexp#=== On Tue, Aug 02, 2005 at 01:36:38AM +0900, Mauricio Fern�ndez wrote: > On Tue, Aug 02, 2005 at 12:51:06AM +0900, daz wrote: > batsman@tux-chan:/tmp$ cat wrapre.rb > > require 'binding_of_caller' [...] > # former results... > p(/x/ === "abxy") # => true > p(Regexp.last_match) # => nil > p(/x/.case_eq("abxy")) # => true > p(Regexp.last_match) # => # > > batsman@tux-chan:/tmp$ ruby wrapre.rb > true > # > true > # I forgot to add that you can probably rewrite Regexp.last_match (using thread-local vars) if you don't really care about $~ itself; the obvious implementation requires several other redefinitions though ({Kernel,String}#gsub(!?), String#scan, etc.). -- Mauricio Fernandez