From: nobu.nokada@... Date: 2002-01-07T11:54:32+09:00 Subject: [ruby-talk:30406] Re: Efficient "lexing" in Ruby (maybe an RCR?) At Mon, 7 Jan 2002 10:30:17 +0900, Matt Armstrong wrote: > Since this is a fairly common thing to do (witness the number of users > of strscan) could we change Regexp#match to take an optional starting > offset? Then the code could be: I agree, and once posted a patch, [ruby-dev:12781]. Or you can use String#index: offset = 0 until offset == string.length if offset = string.index(regexp1, offset) # do something elsif offset = string.index(regexp2, offset) # do something end offset += $&.length # forward end Probably, matched strigs are much less than the source string. -- Nobu Nakada