RegEx string functions
lhmouse opened this issue · 2 comments
lhmouse commented
RegEx string functions
lhmouse commented
|std.string.regex_find(text, pattern)
* Searches `text` for the first occurrence of the regular
expression `pattern`.
* Returns an `array` of two `integer`s, the first of which
specifies the subscript of the matching sequence and the second
of which specifies its length. If `pattern` is not found, this
function returns `null`.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_find(text, from, pattern)
* Searches `text` for the first occurrence of the regular
expression `pattern`. The search operation is performed on the
same subrange that would be returned by `slice(text, from)`.
* Returns an `array` of two `integer`s, the first of which
specifies the subscript of the matching sequence and the second
of which specifies its length. If `pattern` is not found, this
function returns `null`.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_find(text, from, [length], pattern)
* Searches `text` for the first occurrence of the regular
expression `pattern`. The search operation is performed on the
same subrange that would be returned by
`slice(text, from, length)`.
* Returns an `array` of two `integer`s, the first of which
specifies the subscript of the matching sequence and the second
of which specifies its length. If `pattern` is not found, this
function returns `null`.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_match(text, pattern)
* Checks whether the regular expression `patterm` matches the
entire sequence `text`.
* Returns an `array` of `array`s of optional `string`s. The first
element contains a copy of `text`. All the other elements hold
substrings that match positional capturing groups. If a group
matches nothing, the corresponding element is `null`. The total
number of elements equals the number of capturing groups plus
one. If `text` does not match `pattern`, `null` is returned.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_match(text, from, pattern)
* Checks whether the regular expression `patterm` matches the
subrange that would be returned by `slice(text, from)`.
* Returns an `array` of `array`s of optional `string`s. The first
element contains a copy of `text`. All the other elements hold
substrings that match positional capturing groups. If a group
matches nothing, the corresponding element is `null`. The total
number of elements equals the number of capturing groups plus
one. If `text` does not match `pattern`, `null` is returned.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_match(text, from, [length], pattern)
* Checks whether the regular expression `patterm` matches the
subrange that would be returned by `slice(text, from, length)`.
* Returns an `array` of `array`s of optional `string`s. The first
element contains a copy of `text`. All the other elements hold
substrings that match positional capturing groups. If a group
matches nothing, the corresponding element is `null`. The total
number of elements equals the number of capturing groups plus
one. If `text` does not match `pattern`, `null` is returned.
* Throws an exception if `pattern` is not a valid regular
expression.
std.string.regex_replace(text, pattern, replacement)
* Searches `text` and replaces all matches of the regular
expression `pattern` with another regular expression
`replacement`. This function returns a new `string` without
modifying `text`.
* Returns the string with `pattern` replaced. If `text` does not
contain `pattern`, it is returned intact.
* Throws an exception if either `pattern` or `replacement` is not
a valid regular expression.
std.string.regex_replace(text, from, pattern, replacement)
* Searches `text` and replaces all matches of the regular
expression `pattern` with another regular expression
`replacement`. The search operation is performed on the same
subrange that would be returned by `slice(text, from)`. This
function returns a new `string` without modifying `text`.
* Returns the string with `pattern` replaced. If `text` does not
contain `pattern`, it is returned intact.
* Throws an exception if either `pattern` or `replacement` is not
a valid regular expression.
std.string.regex_replace(text, from, [length], pattern, replacement)
* Searches `text` and replaces all matches of the regular
expression `pattern` with another regular expression
`replacement`. The search operation is performed on the same
subrange that would be returned by `slice(text, from, length)`.
This function returns a new `string` without modifying `text`.
* Returns the string with `pattern` replaced. If `text` does not
contain `pattern`, it is returned intact.
* Throws an exception if either `pattern` or `replacement` is not
a valid regular expression.