From: Logan Capaldo Date: 2005-06-21T01:38:57+09:00 Subject: Re: Accessing MatchData results in StringScanner On 6/20/05, Phrogz wrote: > Is it possible using #scan or any other method of StringScanner to get > access to captured sub-expressions in the supplied regexp? > > For example, something like: > ss = StringScanner.new( "Hello __World__" ) > > while ... > if md = ss.scan( /__([^_]+)__/ ) > # I would like md to be a MatchData, not a String > # because I want access to the first capture; > # $1 (which I dislike on principle anyway) is not > # updated by the call to #scan > end > end > > > If the answer is 'no'...might this be a good addition? Perhaps as a new > method (in case returning a MatchData was much slower than a String)? > > > ss[1]