API Reference › Regex › Regex.matches
method

Regex.matches

Regex.matches(text, pattern) -> bool

Searches text for pattern and returns whether it matches anywhere (like a search, not a full-string match — anchor with ^…$ for that). Compiles the pattern each call; for a pattern you use repeatedly, compile once with Regex.compile and use Regex.test.

Parameters

textthe string to search
patternthe regular expression source

Example

program Demo {
  entry {
    if Regex.matches("/quit now", "^/(help|quit)\\b") { print(1) }
  }
}
← All symbols