/
regular_expressions_python.syntax
109 lines (109 loc) · 3.47 KB
/
regular_expressions_python.syntax
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
name: Regular Expressions (Python)
fileTypes:
- re
scopeName: source.regexp.python
repository:
character-class:
patterns:
- name: constant.character.character-class.regexp
match: \\[wWsSdDhH]|\.
- name: constant.character.escape.backslash.regexp
match: \\.
- name: constant.other.character-class.set.regexp
endCaptures:
"1":
name: punctuation.definition.character-class.regexp
begin: (\[)(\^)?
beginCaptures:
"1":
name: punctuation.definition.character-class.regexp
"2":
name: keyword.operator.negation.regexp
end: (\])
patterns:
- include: "#character-class"
- name: constant.other.character-class.range.regexp
captures:
"2":
name: constant.character.escape.backslash.regexp
"4":
name: constant.character.escape.backslash.regexp
match: (.|(\\.))\-([^\]]|(\\.))
uuid: DD867ABF-1EC6-415D-B047-687F550A1D51
foldingStartMarker: (/\*|\{|\()
patterns:
- name: keyword.control.anchor.regexp
match: \\[bBAZzG]|\^|\$
- name: keyword.other.back-reference.regexp
match: \\[1-9][0-9]?
- name: keyword.operator.quantifier.regexp
match: "[?+*][?+]?|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??"
- name: keyword.operator.or.regexp
match: \|
- name: comment.block.regexp
begin: \(\?\#
end: \)
- name: comment.line.number-sign.regexp
match: (?<=^|\s)#\s[[a-zA-Z0-9,. \t?!-:][^\x{00}-\x{7F}]]*$
comment: We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.
- name: keyword.other.option-toggle.regexp
match: \(\?[iLmsux]+\)
- name: keyword.other.back-reference.named.regexp
match: (\()(\?P=([a-zA-Z_][a-zA-Z_0-9]*\w*))(\))
- name: meta.group.assertion.regexp
endCaptures:
"1":
name: punctuation.definition.group.regexp
begin: (\()((\?=)|(\?!)|(\?<=)|(\?<!))
beginCaptures:
"6":
name: meta.assertion.negative-look-behind.regexp
"1":
name: punctuation.definition.group.regexp
"2":
name: punctuation.definition.group.assertion.regexp
"3":
name: meta.assertion.look-ahead.regexp
"4":
name: meta.assertion.negative-look-ahead.regexp
"5":
name: meta.assertion.look-behind.regexp
end: (\))
patterns:
- include: $self
- name: meta.group.assertion.conditional.regexp
begin: (\()(\?\(([1-9][0-9]?|[a-zA-Z_][a-zA-Z_0-9]*)\))
beginCaptures:
"1":
name: punctuation.definition.group.regexp
"2":
name: punctuation.definition.group.assertion.conditional.regexp
"3":
name: entity.name.section.back-reference.regexp
end: (\))
patterns:
- include: $self
comment: we can make this more sophisticated to match the | character that separates yes-pattern from no-pattern, but it's not really necessary.
- name: meta.group.regexp
endCaptures:
"1":
name: punctuation.definition.group.regexp
begin: (\()((\?P<)([a-z]\w*)(>)|(\?:))?
beginCaptures:
"6":
name: punctuation.definition.group.no-capture.regexp
"1":
name: punctuation.definition.group.regexp
"3":
name: punctuation.definition.group.capture.regexp
"4":
name: entity.name.section.group.regexp
"5":
name: punctuation.definition.group.capture.regexp
end: (\))
patterns:
- include: $self
- include: "#character-class"
foldingStopMarker: (\*/|\}|\))
comment: Matches Python's regular expression syntax.