Sha256: dcbb0626323ad74112be8b896596f6d53c7eefa2595bcec74ab67f60cd392cce

Contents?: true

Size: 432 Bytes

Versions: 1

Compression:

Stored size: 432 Bytes

Contents

class Regexp
  # Searches the target for all occurrances of this Regex. If a block is given, yields each match found.
  # Returns an array of all matches found.
  def each_match(target)
    matches = []
    offset = 0
    while offset < target.length && !(match = match(target[offset..-1])).nil?
      offset += match.offset(0)[1]
      yield match if block_given?
      matches << match
    end
    matches
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sc-core-ext-1.1.1 lib/sc-core-ext/regexp.rb