1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| | COMMENT(!MOD!zsh/re2
Interface to the RE2 regular expression library.
!MOD!)
cindex(regular expressions)
cindex(re2)
The tt(zsh/re2) module makes available the following test conditions:
startitem()
findex(re2-match)
item(var(expr) tt(-re2-match) var(regex))(
Matches a string against an RE2 regular expression.
On successful match,
matched portion of the string will normally be placed in the tt(MATCH)
variable. If there are any capturing parentheses within the regex, then
the tt(match) array variable will contain those.
If the match is not successful, then the variables will not be altered.
In addition, the tt(MBEGIN) and tt(MEND) variables are updated to point
to the offsets within var(expr) for the beginning and end of the matched
text, with the tt(mbegin) and tt(mend) arrays holding the beginning and
end of each substring matched.
If tt(BASH_REMATCH) is set, then the array tt(BASH_REMATCH) will be set
instead of all of the other variables.
Canonical documentation for this syntax accepted by this regular expression
engine can be found at:
uref(https://github.com/google/re2/wiki/Syntax)
)
enditem()
startitem()
findex(re2-match-posix)
item(var(expr) tt(-re2-match-posix) var(regex))(
Matches as per tt(-re2-match) but configuring the RE2 engine to use
POSIX syntax.
)
enditem()
startitem()
findex(re2-match-posixperl)
item(var(expr) tt(-re2-match-posixperl) var(regex))(
Matches as per tt(-re2-match) but configuring the RE2 engine to use
POSIX syntax, with the Perl classes and word-boundary extensions re-enabled
too.
This thus adds support for:
tt(\d), tt(\s), tt(\w), tt(\D), tt(\S), tt(\W), tt(\b), and tt(\B).
)
enditem()
startitem()
findex(re2-match-longest)
item(var(expr) tt(-re2-match-longest) var(regex))(
Matches as per tt(-re2-match) but configuring the RE2 engine to find
the longest match, instead of the left-most.
For example, given
example([[ abb -re2-match-longest ^a+LPAR()b|bb+RPAR() ]])
This will match the right-branch, thus tt(abb), where tt(-re2-match) would
instead match only tt(ab).
)
enditem()
|