Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · regexp

Docs

std/regexp

On this page

Index

Types

Regex

struct Regex {}

A compiled expression: an immutable compiled value, comparable (not a handle, decision 0112 addendum).

Source: std/regexp.xo:8

Regex.pattern

fn (r: Regex) pattern() -> Str

Source: std/regexp.xo:24

Regex.is_match

fn (r: Regex) is_match(s: Str) -> Bool

Source: std/regexp.xo:25

Regex.find

fn (r: Regex) find(s: Str) -> Str?

The leftmost match.

Source: std/regexp.xo:27

Regex.find_index

fn (r: Regex) find_index(s: Str) -> (Int, Int)?

The byte offsets (start, end) of the leftmost match.

Source: std/regexp.xo:29

Regex.find_all

fn (r: Regex) find_all(s: Str) -> List[Str]

Every match, left to right, not overlapping.

Source: std/regexp.xo:31

Regex.captures

fn (r: Regex) captures(s: Str) -> List[Str?]?

The leftmost match and its groups: element 0 is the whole match, then one per group, None for a group that did not take part.

Source: std/regexp.xo:34

Regex.named

fn (r: Regex) named(s: Str) -> Map[Str, Str]?

The named groups ((?P<name>...)) of the leftmost match that took part.

Source: std/regexp.xo:36

Regex.replace_all

fn (r: Regex) replace_all(s: Str, repl: Str) -> Str

Every match replaced by repl, in which $1 and ${name} stand for groups ($$ for a dollar sign).

Source: std/regexp.xo:39

Regex.replace_all_literal

fn (r: Regex) replace_all_literal(s: Str, repl: Str) -> Str

Every match replaced by repl as written (no $ expansion).

Source: std/regexp.xo:41

Regex.split

fn (r: Regex) split(s: Str) -> List[Str]

s split around the matches.

Source: std/regexp.xo:43

RegexErr

struct RegexErr {
  pattern: Str
  msg: Str
}

Displays as invalid regexp "(a": missing closing ): ....

Source: std/regexp.xo:11

RegexErr.display

fn (e: RegexErr) display() -> Str

Source: std/regexp.xo:16

Functions

compile

fn compile(pattern: Str) -> Regex ! RegexErr

Source: std/regexp.xo:18

must

fn must(pattern: Str) -> Regex

compile, faulting on a bad pattern (for patterns written in the program).

Source: std/regexp.xo:20

quote

fn quote(text: Str) -> Str

text with every metacharacter escaped: a pattern matching text literally.

Source: std/regexp.xo:22

↑ index