Definition: |
include builtins\regex.e
sequence m = regex(sequence re, string target) |
Description: |
Applies the regular expression re (in string or pre-compiled format) to target and returns an array of group
indexes or {} if no match could be found.
re: a regular expression such as "a(b*)" or the result of applying regex_compile() to such a string. target: a string to be matched against the regular expression. Returns: an even-length sequence of group indexes, or {} if no match could be found. |
Example: |
?regex(`(a)(bc)`,"abc") -- yields {1,4, 1,2, 2,4} The result is 3 pairs of start/end+1 indexes, which can be read as {"abc"[1..4-1],"a"[1..2-1],"bc"[2..4-1]}. The first element, aka `\0` is the entire match, the second aka `\1` from `(a)` is "a", and obviously the third aka `\2` from `(bc)` is "bc". |
See Also: | regex syntax |