-
Notifications
You must be signed in to change notification settings - Fork 0
/
zpregex.zp
51 lines (42 loc) · 1.71 KB
/
zpregex.zp
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
(define (regex:in? r pattern)
"checks whether a regex <par>r</par> is in a string <par>pattern</par>.
params:
- r: the regex to match against
- pattern: the pattern to check
complexity: derived from <fun>regex:scan</fun>
returns: a boolean"
(|> (regex:scan r pattern) null? not))
(define (regex:groups r pattern)
"gets match groups of the scan of <par>r<par> over the <par>pattern</par>.
params:
- r: the regex to match against
- pattern: the pattern to check
complexity: derived from <fun>regex:scan</fun>
returns: a list of the groups defined in <par>r</par> as found in <par>pattern</par>"
(map cadr (regex:scan r pattern)))
(define (regex:matches r pattern)
"gets all matches of the scan of <par>r<par> over the <par>pattern</par>.
params:
- r: the regex to match against
- pattern: the pattern to check
complexity: derived from <fun>regex:scan</fun>
returns: a list of the matches"
(map car (regex:scan r pattern)))
(define (regex:groups-indices r pattern)
"gets indices of match groups of the scan of <par>r<par> over
the <par>pattern</par>.
params:
- r: the regex to match against
- pattern: the pattern to check
complexity: derived from <fun>regex:scan</fun>
returns: a list of the indices of the groups defined in <par>r</par> as found in <par>pattern</par>"
(map cadr (regex:scan-ranges r pattern)))
(define (regex:matches-indices r pattern)
"gets all index of matches of the scan of <par>r<par> over the
<par>pattern</par>.
params:
- r: the regex to match against
- pattern: the pattern to check
complexity: derived from <fun>regex:scan</fun>
returns: a list of the match indices"
(map car (regex:scan-ranges r pattern)))