Alpha. Vary is under active development and not ready for production use. Syntax, APIs, performance, and behaviour may change between releases.
Regex
let re = Regex.compile("(\\w+)\\s+(\\w+)")
let m = re.find("hello world")
if m is not None {
print(m!!.group(0)) # hello world
print(m!!.group(1)) # hello
print(m!!.group(2)) # world
}
let digits = Regex.compile("\\d+")
let matches = digits.find_all("abc 123 def 456")
print(len(matches)) # 2
| Method | Returns | Description |
|---|---|---|
Regex.compile(pattern) | Regex | Compile a regex |
.find(input) | Match? | First match |
.find_all(input) | List[Match] | All non-overlapping matches |
.replace_all(input, replacement) | Str | Replace all matches |
.replace_first(input, replacement) | Str | Replace first match |
.group(index) | Str? | Capture group (0 = full match) |
.groups() | List[Str?] | All groups |