From: nobu.nokada@... Date: 2002-12-13T06:59:36+09:00 Subject: Re: [RCR] Global Regexp Match Mechanism (//g) Hi, At Fri, 13 Dec 2002 04:31:12 +0900, Austin Ziegler wrote: > #scan doesn't solve the ultimate problem -- being able to > backtrack and rescan from an earlier position (a la Perl's > pos() function). Scan would work "OK" if it returned an array > of MatchData instead of Strings. BTW, my posted code almost > works. I meant to say that I wanted to do that without doing > "foostr = md.post_match". String#index takes optional argument specifies searching position. pos = 0 while foostr.index(/foo/, pos) puts $& pos = $~.end(0) end Optional argument to Regexp#match somebody had proposed would be nice too. pos = 0 while md = /foo/.match(foostr, pos) puts md.to_s pos = md.end(0) end -- Nobu Nakada