std/regex
Regular expressions backed by Go’s RE2-compatible regexp engine.
Use raw typed literals for readable patterns, such as Regex`\d+.
Import with import std/regex.
Exports
Section titled “Exports”Types
type Regex
Section titled “type Regex”type Regex
opaque — construction surface is private to its defining module
A compiled regular expression.
Nomi regexes use Go’s regexp package, so matching is RE2-style:
predictable and non-backtracking, without lookaround or backreferences.
Prefer raw typed literals for patterns so regex escapes stay readable:
try Regex`\d+.
Regex.compile
Section titled “Regex.compile”fn compile(pattern: String): Result<Regex, String>
type function on Regex
Compile a pattern into a Regex.
Regex.pattern
Section titled “Regex.pattern”fn pattern(re: Regex): String
type function on Regex
Return the source pattern for a compiled regex.
Regex.match?
Section titled “Regex.match?”fn match?(re: Regex, value: String): Bool
type function on Regex
True if the regex matches anywhere in value.
Regex.find
Section titled “Regex.find”fn find(re: Regex, value: String): Maybe<String>
type function on Regex
Return the first matching substring.
Regex.find_all
Section titled “Regex.find_all”fn find_all(re: Regex, value: String): List<String>
type function on Regex
Return every non-overlapping matching substring.
Regex.replace_all
Section titled “Regex.replace_all”fn replace_all(re: Regex, value: String, replacement: String): String
type function on Regex
Replace every non-overlapping match with replacement.
Replacement text follows Go’s regexp rules, so $1, ${name}, and
friends expand capture groups.
Regex.split
Section titled “Regex.split”fn split(re: Regex, value: String): List<String>
type function on Regex
Split around every non-overlapping match.
Regex.from_fragments
Section titled “Regex.from_fragments”fn from_fragments(fragments: List<Fragment<String>>): Result<Regex, String>
Regex.to_string
Section titled “Regex.to_string”fn to_string(re: Regex): String
impl Display.to_string
The source pattern.
Regex.inspect
Section titled “Regex.inspect”fn inspect(re: Regex): String
impl Debug.inspect