API Reference › Regex › Regex.find
method

Regex.find

Regex.find(text, pattern) -> Match

Searches text and returns the first Match — carrying the overall span and every capture group — or null if the pattern does not match. Read groups with Regex.group and spans with Regex.start / Regex.end.

Parameters

textthe string to search
patternthe regular expression source

Example

program Demo {
  entry {
    let m = Regex.find("name: Alice", "(\\w+): (\\w+)")
    if Regex.ok(m) { print(1) }
  }
}
← All symbols