At Mon, 7 Jan 2002 10:30:17 +0900,
Matt Armstrong <matt+dated+1010799012.80728c / lickey.com> 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