API Reference › Regex › Regex.next
method

Regex.next

Regex.next(text, re, from) -> Match

Returns the first match of re in text starting at or after byte offset from, or null. Loop it from the previous match's end (see Regex.end) to iterate every match — the find-all idiom.

Parameters

textthe string to search
rea compiled Regex
fromthe byte offset to resume from

Example

program Demo {
  entry {
    let re = Regex.compile("#(\\w+)")
    var m = Regex.exec("#a #b #c", re)
    while Regex.ok(m) {
      print(Regex.group(m, 1))
      m = Regex.next("#a #b #c", re, Regex.end(m, 0))
    }
  }
}
← All symbols