Reference

std/regex

Regular expressions with the syntax and the semantics of RE2, written in TorbScript: Regex compiles a pattern once, and matching runs in time linear in the length of the text - there is no backtracking, so there are no backreferences and no lookaround, and no pattern can take a program down with a text it was handed. The engine is the same code in the VM and in a native binary, so both answer the same.

const pattern: Regex = "(?P<key>\w+)=(?P<value>\w+)"
for found in pattern.findAll("a=1 b=2") {
  print "{found.named("key")} is {found.named("value")}"
}

A pattern works on characters, and every position it answers is a byte offset into the text, as every position of a String is. Named groups decode into a type through Decode (RegexMatch.decoded). A literal where a Regex is expected is compiled by the compiler where it is written, and read verbatim, so \d and {2,4} need no raw.

Modules

Everything