forked from sublimehq/Packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegular Expressions (JavaScript).sublime-syntax
More file actions
131 lines (120 loc) · 4.29 KB
/
Regular Expressions (JavaScript).sublime-syntax
File metadata and controls
131 lines (120 loc) · 4.29 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
%YAML 1.2
---
name: Regular Expressions (Javascript)
scope: source.regexp.js
hidden: true
variables:
identifier: '[_$[:alpha:]][_$[:alnum:]]*'
contexts:
main:
- include: anchor
- include: backref
- include: quantifier
- include: operator
- include: group-assertion
- include: group-definition
- include: character-class
- include: character-class-definition
anchor:
- match: '\\[bB]|\^|\$'
scope: keyword.control.anchor.regexp
backref:
- match: '\\[1-9][0-9]*'
scope: keyword.other.back-reference.regexp
- match: (\\k)(<)({{identifier}})(>)
captures:
1: keyword.other.back-reference.regexp
2: punctuation.definition.group.named.begin.regexp
3: variable.other.group.regexp
4: punctuation.definition.group.named.end.regexp
character-class:
- match: '\\[wWsSdD]|\.'
scope: constant.other.character-class.escape.backslash.regexp
- match: '(\\[pP])(\{)([[:alpha:]_]+)(?:(=)([[:alpha:]_]+)?)?(\})'
captures:
1: constant.other.character-class.escape.unicode-property.regexp
2: punctuation.definition.unicode-property.begin.regexp
3: support.constant.unicode-property.regexp
4: punctuation.separator.key-value.unicode-property.regexp
5: support.constant.unicode-property.regexp
6: punctuation.definition.unicode-property.end.regexp
- match: '\\([trnvf0\\]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.)'
scope: constant.character.escape.backslash.regexp
character-class-definition:
- match: '(\[)(\^)?'
captures:
1: punctuation.definition.character-class.begin.regexp
2: keyword.operator.negation.regexp
push:
- meta_scope: constant.other.character-class.set.regexp
- match: '\]'
scope: punctuation.definition.character-class.end.regexp
pop: true
- match: |-
(?x)
(?:
(\\[wWsSdD]|\.)|
(\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
.
)
(\-)
(?:
(\\[wWsSdD]|\.)|
(\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
[^]]
)
scope: constant.other.character-class.range.regexp
captures:
1: constant.other.character-class.escape.backslash.regexp
2: constant.character.escape.backslash.regexp
3: punctuation.definition.range.regexp
4: constant.other.character-class.escape.backslash.regexp
5: constant.character.escape.backslash.regexp
- include: character-class
group-assertion:
- match: (\()((\?=)|(\?!)|(\?<=)|(\?<!))
captures:
1: punctuation.definition.group.begin.regexp
2: punctuation.definition.group.assertion.regexp
3: meta.assertion.look-ahead.regexp
4: meta.assertion.negative-look-ahead.regexp
5: meta.assertion.look-behind.regexp
6: meta.assertion.negative-look-behind.regexp
push:
- meta_scope: meta.group.assertion.regexp
- match: \)
scope: punctuation.definition.group.end.regexp
pop: true
- include: main
group-definition:
- match: (\()(?:(\?:)|(\?)(<)({{identifier}})(>))?
captures:
1: punctuation.definition.group.begin.regexp
2: punctuation.definition.group.no-capture.regexp
3: punctuation.definition.group.begin.regexp
4: punctuation.definition.group.named.begin.regexp
5: entity.name.other.group.regexp
6: punctuation.definition.group.named.end.regexp
push:
- meta_scope: meta.group.regexp
- match: \)
scope: punctuation.definition.group.end.regexp
pop: true
- include: main
operator:
- match: \|
scope: keyword.operator.or.regexp
quantifier:
- match: '[?*+]\??'
scope: keyword.operator.quantifier.regexp
- match: '\{(\d+)(?:(,)(\d+)?)?\}'
scope: keyword.operator.quantifier.regexp
captures:
1: constant.literal.numeric.regexp
2: punctuation.separator.comma.regexp
3: constant.literal.numeric.regexp
- match: \{(,)(\d+)\}
scope: keyword.operator.quantifier.regexp
captures:
1: punctuation.separator.comma.regexp
2: constant.literal.numeric.regexp