From: "David A. Black" Date: 2008-05-05T00:22:04+09:00 Subject: Re: Backreferences in case statements --1926193751-135900924-1209914523=:31509 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-135900924-1209914523=:31509" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-135900924-1209914523=:31509 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Sun, 4 May 2008, loveajax@gmail.com wrote: > On May 4, 5:40=A0am, Pit Capitain wrote: >> 2008/5/3 =A0: >> >>> =A0Where does Ruby store the MatchData if the >>> =A0matching is done in a case statement? Matching doesn't change in or out of a case statement; it's still the same thing. >> Subbu, there's also Regexp.last_match. Sometimes this reads better >> than those Perl-like variables. >> >> Regards, >> Pit > > Hi Pitt, > > I did use Regexp.last_match. But its a class method. I am interested > in using something like pre_match and post_match methods which are > instance variables. But looks like my code never created the instance > of MatchData. Methods aren't instance variables; they're methods :-) Ruby keeps track of the last match operation performed, and that's what you get in $~ (which is a MatchData object) and some of the Regexp class methods. David --=20 Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates! --1926193751-135900924-1209914523=:31509-- --1926193751-135900924-1209914523=:31509--