-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathRegex.ql
More file actions
28 lines (26 loc) · 847 Bytes
/
Regex.ql
File metadata and controls
28 lines (26 loc) · 847 Bytes
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
import python
import semmle.python.regex
predicate part(RegExp r, int start, int end, string kind) {
r.alternation(start, end) and kind = "choice"
or
r.normalCharacter(start, end) and kind = "char"
or
r.escapedCharacter(start, end) and
kind = "char" and
not r.specialCharacter(start, end, _)
or
r.specialCharacter(start, end, kind)
or
r.sequence(start, end) and kind = "sequence"
or
r.charSet(start, end) and kind = "char-set"
or
r.zeroWidthMatch(start, end) and kind = "empty group"
or
r.group(start, end) and not r.zeroWidthMatch(start, end) and kind = "non-empty group"
or
r.qualifiedItem(start, end, _, _) and kind = "qualified"
}
from RegExp r, int start, int end, string kind
where part(r, start, end, kind) and r.getLocation().getFile().getBaseName() = "test.py"
select r.getText(), kind, start, end