regex
Regular expressions, the regex-lite dialect: no look-around or back-references. A pattern is compiled on every call; a match is #{ start, end, text, groups } with byte offsets and one string per capture group, nil for a group that took no part.
6 functions, 0 constants. Scripts reach it as regex::.
Functions
Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.
| function | acts on | what it does |
|---|---|---|
escape(text: string) -> string | — | text with every metacharacter escaped, so it matches itself. |
matches(pattern: string, text: string) -> bool | — | Whether the pattern matches anywhere in text. |
replace(pattern: string, text: string, with: string, all: bool?) -> string | — | text with the first match replaced, or every match when all is true; $1 and ${name} in with stand for groups. |
search(pattern: string, text: string) -> table? | — | The first match, or nil. |
search_all(pattern: string, text: string) -> [table] | — | Every non-overlapping match, in order. |
split(pattern: string, text: string) -> [string] | — | The pieces of text between matches. |