API
#regexp
Xu 0.8.8 API
import: #regexp
counts: 2 fns, 14 methods, 4 types, 0 consts, 0 ifaces
Regexp subset: compile/match/find/replace; bounded backtracking.
struct Regexp
pub struct Regexp {
pub nodes []Node
pub root int
pub class_data string
pub steps_max int
pub num_caps int
}
Purpose
Public struct `Regexp`.
Parameters
nodes []Node- field ([]Node)
root int- field (int)
class_data string- field (string)
steps_max int- field (int)
num_caps int- field (int)
quote_meta
pub fn quote_meta(s &string) string
Purpose
Quote meta.
Parameters
s &string- source string (borrowed; caller keeps it; type &string)
Returns
string — result string
compile
pub fn compile(expr string) Regexp
Purpose
compile; returns Regexp. Throws on failure.
Parameters
expr string- expr (string)
Returns
Regexp — a value of this type
(Regexp) num_subexp
pub fn (re Regexp) num_subexp() int
Purpose
Method on `Regexp`: num subexp.
Parameters
re Regexp- receiver Regexp (value receiver)
Returns
int — a value of this type
(Regexp) find_submatch
pub fn (re Regexp) find_submatch(s &string) []string
Purpose
Method on `Regexp`: find submatch.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
Returns
[]string — slice result
struct Submatch
pub struct Submatch {
pub start int
pub end int
pub parts []string
}
Purpose
Public struct `Submatch`.
Parameters
start int- field (int)
end int- field (int)
parts []string- parts
(Regexp) find_all_submatch
pub fn (re Regexp) find_all_submatch(s &string, n int) [][]string
Purpose
Method on `Regexp`: find all submatch.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
n int- count, length, or limit (int)
Returns
[][]string — slice result
(Regexp) expand
pub fn (re Regexp) expand(s &string, repl &string) string
Purpose
Call `expand` on `Regexp`.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
repl &string- repl (borrowed; caller keeps it; type &string)
Returns
string — result string
struct LiteralPrefix
pub struct LiteralPrefix {
pub prefix string
pub complete bool
}
Purpose
Public struct `LiteralPrefix`.
Parameters
prefix string- prefix
complete bool- field (bool)
(Regexp) literal_prefix
pub fn (re Regexp) literal_prefix() LiteralPrefix
Purpose
Method on `Regexp`: literal prefix.
Parameters
re Regexp- receiver Regexp (value receiver)
Returns
LiteralPrefix — a value of this type
(Regexp) match_string
pub fn (re Regexp) match_string(s &string) bool
Purpose
Method on `Regexp`: match string.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
Returns
bool — true or false
(Regexp) find
pub fn (re Regexp) find(s &string) string
Purpose
Call `find` on `Regexp`.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
Returns
string — result string
struct Index
pub struct Index {
pub start int
pub end int
}
Purpose
Public struct `Index`.
Parameters
start int- field (int)
end int- field (int)
(Regexp) find_index
pub fn (re Regexp) find_index(s &string) Index
Purpose
Method on `Regexp`: find index.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
Returns
Index — a value of this type
(Regexp) find_all_index
pub fn (re Regexp) find_all_index(s &string, n int) []Index
Purpose
Method on `Regexp`: find all index.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
n int- count, length, or limit (int)
Returns
[]Index — slice result
(Regexp) find_all
pub fn (re Regexp) find_all(s &string, n int) []string
Purpose
Method on `Regexp`: find all.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
n int- count, length, or limit (int)
Returns
[]string — slice result
(Regexp) split
pub fn (re Regexp) split(s &string, n int) []string
Purpose
Method on `Regexp`: split on the separator.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
n int- count, length, or limit (int)
Returns
[]string — slice result
(Regexp) find_submatch_index
pub fn (re Regexp) find_submatch_index(s &string) []Index
Purpose
Method on `Regexp`: find submatch index.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
Returns
[]Index — slice result
(Regexp) replace_all_literal
pub fn (re Regexp) replace_all_literal(s &string, repl &string) string
Purpose
Method on `Regexp`: replace all literal.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
repl &string- repl (borrowed; caller keeps it; type &string)
Returns
string — result string
(Regexp) replace_all
pub fn (re Regexp) replace_all(s &string, repl &string) string
Purpose
Method on `Regexp`: replace every occurrence of the substring.
Parameters
re Regexp- receiver Regexp (value receiver)
s &string- source string (borrowed; caller keeps it; type &string)
repl &string- repl (borrowed; caller keeps it; type &string)
Returns
string — result string