OLD | NEW |
1 RE2 regular expression syntax reference | 1 RE2 regular expression syntax reference |
2 ------------------------------------- | 2 ------------------------------------- |
3 | 3 |
4 Single characters: | 4 Single characters: |
5 . any character, possibly including newline (s=true) | 5 . any character, possibly including newline (s=true) |
6 [xyz] character class | 6 [xyz] character class |
7 [^xyz] negated character class | 7 [^xyz] negated character class |
8 \d Perl character class | 8 \d Perl character class |
9 \D negated Perl character class | 9 \D negated Perl character class |
10 [[:alpha:]]» ASCII character class | 10 [:alpha:]» ASCII character class |
11 [[:^alpha:]]» negated ASCII character class | 11 [:^alpha:]» negated ASCII character class |
12 \pN Unicode character class (one-letter name) | 12 \pN Unicode character class (one-letter name) |
13 \p{Greek} Unicode character class | 13 \p{Greek} Unicode character class |
14 \PN negated Unicode character class (one-letter name) | 14 \PN negated Unicode character class (one-letter name) |
15 \P{Greek} negated Unicode character class | 15 \P{Greek} negated Unicode character class |
16 | 16 |
17 Composites: | 17 Composites: |
18 xy «x» followed by «y» | 18 xy «x» followed by «y» |
19 x|y «x» or «y» (prefer «x») | 19 x|y «x» or «y» (prefer «x») |
20 | 20 |
21 Repetitions: | 21 Repetitions: |
22 x* zero or more «x», prefer more | 22 x* zero or more «x», prefer more |
23 x+ one or more «x», prefer more | 23 x+ one or more «x», prefer more |
24 x? zero or one «x», prefer one | 24 x? zero or one «x», prefer one |
25 x{n,m} «n» or «n»+1 or ... or «m» «x», prefer more | 25 x{n,m} «n» or «n»+1 or ... or «m» «x», prefer more |
26 x{n,} «n» or more «x», prefer more | 26 x{n,} «n» or more «x», prefer more |
27 x{n} exactly «n» «x» | 27 x{n} exactly «n» «x» |
28 x*? zero or more «x», prefer fewer | 28 x*? zero or more «x», prefer fewer |
29 x+? one or more «x», prefer fewer | 29 x+? one or more «x», prefer fewer |
30 x?? zero or one «x», prefer zero | 30 x?? zero or one «x», prefer zero |
31 x{n,m}? «n» or «n»+1 or ... or «m» «x», prefer fewer | 31 x{n,m}? «n» or «n»+1 or ... or «m» «x», prefer fewer |
32 x{n,}? «n» or more «x», prefer fewer | 32 x{n,}? «n» or more «x», prefer fewer |
33 x{n}? exactly «n» «x» | 33 x{n}? exactly «n» «x» |
34 x{} (== x*) NOT SUPPORTED vim | 34 x{} (== x*) NOT SUPPORTED vim |
35 x{-} (== x*?) NOT SUPPORTED vim | 35 x{-} (== x*?) NOT SUPPORTED vim |
36 x{-n} (== x{n}?) NOT SUPPORTED vim | 36 x{-n} (== x{n}?) NOT SUPPORTED vim |
37 x= (== x?) NOT SUPPORTED vim | 37 x= (== x?) NOT SUPPORTED vim |
38 | 38 |
39 Implementation restriction: The counting forms «x{n,m}», «x{n,}», and «x{n}» | |
40 reject forms that create a minimum or maximum repetition count above 1000. | |
41 Unlimited repetitions are not subject to this restriction. | |
42 | |
43 Possessive repetitions: | 39 Possessive repetitions: |
44 x*+ zero or more «x», possessive NOT SUPPORTED | 40 x*+ zero or more «x», possessive NOT SUPPORTED |
45 x++ one or more «x», possessive NOT SUPPORTED | 41 x++ one or more «x», possessive NOT SUPPORTED |
46 x?+ zero or one «x», possessive NOT SUPPORTED | 42 x?+ zero or one «x», possessive NOT SUPPORTED |
47 x{n,m}+ «n» or ... or «m» «x», possessive NOT SUPPORTED | 43 x{n,m}+ «n» or ... or «m» «x», possessive NOT SUPPORTED |
48 x{n,}+ «n» or more «x», possessive NOT SUPPORTED | 44 x{n,}+ «n» or more «x», possessive NOT SUPPORTED |
49 x{n}+ exactly «n» «x», possessive NOT SUPPORTED | 45 x{n}+ exactly «n» «x», possessive NOT SUPPORTED |
50 | 46 |
51 Grouping: | 47 Grouping: |
52 (re)» numbered capturing group (submatch) | 48 (re)» numbered capturing group |
53 (?P<name>re)» named & numbered capturing group (submatch) | 49 (?P<name>re)» named & numbered capturing group |
54 (?<name>re)» named & numbered capturing group (submatch) NOT SUPPORTED | 50 (?<name>re)» named & numbered capturing group NOT SUPPORTED |
55 (?'name're)» named & numbered capturing group (submatch) NOT SUPPORTED | 51 (?'name're)» named & numbered capturing group NOT SUPPORTED |
56 (?:re) non-capturing group | 52 (?:re) non-capturing group |
57 (?flags) set flags within current group; non-capturing | 53 (?flags) set flags within current group; non-capturing |
58 (?flags:re) set flags during re; non-capturing | 54 (?flags:re) set flags during re; non-capturing |
59 (?#text) comment NOT SUPPORTED | 55 (?#text) comment NOT SUPPORTED |
60 (?|x|y|z) branch numbering reset NOT SUPPORTED | 56 (?|x|y|z) branch numbering reset NOT SUPPORTED |
61 (?>re) possessive match of «re» NOT SUPPORTED | 57 (?>re) possessive match of «re» NOT SUPPORTED |
62 re@> possessive match of «re» NOT SUPPORTED vim | 58 re@> possessive match of «re» NOT SUPPORTED vim |
63 %(re) non-capturing group NOT SUPPORTED vim | 59 %(re) non-capturing group NOT SUPPORTED vim |
64 | 60 |
65 Flags: | 61 Flags: |
66 i case-insensitive (default false) | 62 i case-insensitive (default false) |
67 m multi-line mode: «^» and «$» match begin/end line in addition to begin/e
nd text (default false) | 63 m multi-line mode: «^» and «$» match begin/end line in addition to begin/e
nd text (default false) |
68 s let «.» match «\n» (default false) | 64 s let «.» match «\n» (default false) |
69 U ungreedy: swap meaning of «x*» and «x*?», «x+» and «x+?», etc (default f
alse) | 65 U ungreedy: swap meaning of «x*» and «x*?», «x+» and «x+?», etc (default f
alse) |
70 Flag syntax is «xyz» (set) or «-xyz» (clear) or «xy-z» (set «xy», clear «z»). | 66 Flag syntax is «xyz» (set) or «-xyz» (clear) or «xy-z» (set «xy», clear «z»). |
71 | 67 |
72 Empty strings: | 68 Empty strings: |
73 ^ at beginning of text or line («m»=true) | 69 ^ at beginning of text or line («m»=true) |
74 $ at end of text (like «\z» not «\Z») or line («m»=true) | 70 $ at end of text (like «\z» not «\Z») or line («m»=true) |
75 \A at beginning of text | 71 \A at beginning of text |
76 \b» at ASCII word boundary («\w» on one side and «\W», «\A», or «\z» on the
other) | 72 \b» at word boundary («\w» on one side and «\W», «\A», or «\z» on the other) |
77 \B» not at ASCII word boundary | 73 \B» not a word boundary |
78 \G at beginning of subtext being searched NOT SUPPORTED pcre | 74 \G at beginning of subtext being searched NOT SUPPORTED pcre |
79 \G at end of last match NOT SUPPORTED perl | 75 \G at end of last match NOT SUPPORTED perl |
80 \Z at end of text, or before newline at end of text NOT SUPPORTED | 76 \Z at end of text, or before newline at end of text NOT SUPPORTED |
81 \z at end of text | 77 \z at end of text |
82 (?=re) before text matching «re» NOT SUPPORTED | 78 (?=re) before text matching «re» NOT SUPPORTED |
83 (?!re) before text not matching «re» NOT SUPPORTED | 79 (?!re) before text not matching «re» NOT SUPPORTED |
84 (?<=re) after text matching «re» NOT SUPPORTED | 80 (?<=re) after text matching «re» NOT SUPPORTED |
85 (?<!re) after text not matching «re» NOT SUPPORTED | 81 (?<!re) after text not matching «re» NOT SUPPORTED |
86 re& before text matching «re» NOT SUPPORTED vim | 82 re& before text matching «re» NOT SUPPORTED vim |
87 re@= before text matching «re» NOT SUPPORTED vim | 83 re@= before text matching «re» NOT SUPPORTED vim |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 Named character classes as character class elements: | 148 Named character classes as character class elements: |
153 [\d] digits (== \d) | 149 [\d] digits (== \d) |
154 [^\d] not digits (== \D) | 150 [^\d] not digits (== \D) |
155 [\D] not digits (== \D) | 151 [\D] not digits (== \D) |
156 [^\D] not not digits (== \d) | 152 [^\D] not not digits (== \d) |
157 [[:name:]] named ASCII class inside character class (== [:name:]) | 153 [[:name:]] named ASCII class inside character class (== [:name:]) |
158 [^[:name:]] named ASCII class inside negated character class (== [:^name:]) | 154 [^[:name:]] named ASCII class inside negated character class (== [:^name:]) |
159 [\p{Name}] named Unicode property inside character class (== \p{Name}) | 155 [\p{Name}] named Unicode property inside character class (== \p{Name}) |
160 [^\p{Name}] named Unicode property inside negated character class (== \P{Nam
e}) | 156 [^\p{Name}] named Unicode property inside negated character class (== \P{Nam
e}) |
161 | 157 |
162 Perl character classes (all ASCII-only): | 158 Perl character classes: |
163 \d digits (== [0-9]) | 159 \d digits (== [0-9]) |
164 \D not digits (== [^0-9]) | 160 \D not digits (== [^0-9]) |
165 \s whitespace (== [\t\n\f\r ]) | 161 \s whitespace (== [\t\n\f\r ]) |
166 \S not whitespace (== [^\t\n\f\r ]) | 162 \S not whitespace (== [^\t\n\f\r ]) |
167 \w word characters (== [0-9A-Za-z_]) | 163 \w word characters (== [0-9A-Za-z_]) |
168 \W not word characters (== [^0-9A-Za-z_]) | 164 \W not word characters (== [^0-9A-Za-z_]) |
169 | 165 |
170 \h horizontal space NOT SUPPORTED | 166 \h horizontal space NOT SUPPORTED |
171 \H not horizontal space NOT SUPPORTED | 167 \H not horizontal space NOT SUPPORTED |
172 \v vertical space NOT SUPPORTED | 168 \v vertical space NOT SUPPORTED |
173 \V not vertical space NOT SUPPORTED | 169 \V not vertical space NOT SUPPORTED |
174 | 170 |
175 ASCII character classes: | 171 ASCII character classes: |
176 [[:alnum:]]» alphanumeric (== [0-9A-Za-z]) | 172 [:alnum:]» alphanumeric (== [0-9A-Za-z]) |
177 [[:alpha:]]» alphabetic (== [A-Za-z]) | 173 [:alpha:]» alphabetic (== [A-Za-z]) |
178 [[:ascii:]]» ASCII (== [\x00-\x7F]) | 174 [:ascii:]» ASCII (== [\x00-\x7F]) |
179 [[:blank:]]» blank (== [\t ]) | 175 [:blank:]» blank (== [\t ]) |
180 [[:cntrl:]]» control (== [\x00-\x1F\x7F]) | 176 [:cntrl:]» control (== [\x00-\x1F\x7F]) |
181 [[:digit:]]» digits (== [0-9]) | 177 [:digit:]» digits (== [0-9]) |
182 [[:graph:]]» graphical (== [!-~] == [A-Za-z0-9!"#$%&'()*+,\-./:;<=>?@[\\\]^_`
{|}~]) | 178 [:graph:]» graphical (== [!-~] == [A-Za-z0-9!"#$%&'()*+,\-./:;<=>?@[\\\]^_`
{|}~]) |
183 [[:lower:]]» lower case (== [a-z]) | 179 [:lower:]» lower case (== [a-z]) |
184 [[:print:]]» printable (== [ -~] == [ [:graph:]]) | 180 [:print:]» printable (== [ -~] == [ [:graph:]]) |
185 [[:punct:]]» punctuation (== [!-/:-@[-`{-~]) | 181 [:punct:]» punctuation (== [!-/:-@[-`{-~]) |
186 [[:space:]]» whitespace (== [\t\n\v\f\r ]) | 182 [:space:]» whitespace (== [\t\n\v\f\r ]) |
187 [[:upper:]]» upper case (== [A-Z]) | 183 [:upper:]» upper case (== [A-Z]) |
188 [[:word:]]» word characters (== [0-9A-Za-z_]) | 184 [:word:]» word characters (== [0-9A-Za-z_]) |
189 [[:xdigit:]]» hex digit (== [0-9A-Fa-f]) | 185 [:xdigit:]» hex digit (== [0-9A-Fa-f]) |
190 | 186 |
191 Unicode character class names--general category: | 187 Unicode character class names--general category: |
192 C other | 188 C other |
193 Cc control | 189 Cc control |
194 Cf format | 190 Cf format |
195 Cn unassigned code points NOT SUPPORTED | 191 Cn unassigned code points NOT SUPPORTED |
196 Co private use | 192 Co private use |
197 Cs surrogate | 193 Cs surrogate |
198 L letter | 194 L letter |
199 LC cased letter NOT SUPPORTED | 195 LC cased letter NOT SUPPORTED |
(...skipping 26 matching lines...) Expand all Loading... |
226 So other symbol | 222 So other symbol |
227 Z separator | 223 Z separator |
228 Zl line separator | 224 Zl line separator |
229 Zp paragraph separator | 225 Zp paragraph separator |
230 Zs space separator | 226 Zs space separator |
231 | 227 |
232 Unicode character class names--scripts: | 228 Unicode character class names--scripts: |
233 Arabic Arabic | 229 Arabic Arabic |
234 Armenian Armenian | 230 Armenian Armenian |
235 Balinese Balinese | 231 Balinese Balinese |
236 Bamum Bamum | |
237 Batak Batak | |
238 Bengali Bengali | 232 Bengali Bengali |
239 Bopomofo Bopomofo | 233 Bopomofo Bopomofo |
240 Brahmi Brahmi | |
241 Braille Braille | 234 Braille Braille |
242 Buginese Buginese | 235 Buginese Buginese |
243 Buhid Buhid | 236 Buhid Buhid |
244 Canadian_Aboriginal Canadian Aboriginal | 237 Canadian_Aboriginal Canadian Aboriginal |
245 Carian Carian | 238 Carian Carian |
246 Chakma Chakma | |
247 Cham Cham | 239 Cham Cham |
248 Cherokee Cherokee | 240 Cherokee Cherokee |
249 Common characters not specific to one script | 241 Common characters not specific to one script |
250 Coptic Coptic | 242 Coptic Coptic |
251 Cuneiform Cuneiform | 243 Cuneiform Cuneiform |
252 Cypriot Cypriot | 244 Cypriot Cypriot |
253 Cyrillic Cyrillic | 245 Cyrillic Cyrillic |
254 Deseret Deseret | 246 Deseret Deseret |
255 Devanagari Devanagari | 247 Devanagari Devanagari |
256 Egyptian_Hieroglyphs Egyptian Hieroglyphs | |
257 Ethiopic Ethiopic | 248 Ethiopic Ethiopic |
258 Georgian Georgian | 249 Georgian Georgian |
259 Glagolitic Glagolitic | 250 Glagolitic Glagolitic |
260 Gothic Gothic | 251 Gothic Gothic |
261 Greek Greek | 252 Greek Greek |
262 Gujarati Gujarati | 253 Gujarati Gujarati |
263 Gurmukhi Gurmukhi | 254 Gurmukhi Gurmukhi |
264 Han Han | 255 Han Han |
265 Hangul Hangul | 256 Hangul Hangul |
266 Hanunoo Hanunoo | 257 Hanunoo Hanunoo |
267 Hebrew Hebrew | 258 Hebrew Hebrew |
268 Hiragana Hiragana | 259 Hiragana Hiragana |
269 Imperial_Aramaic Imperial Aramaic | |
270 Inherited inherit script from previous character | 260 Inherited inherit script from previous character |
271 Inscriptional_Pahlavi Inscriptional Pahlavi | |
272 Inscriptional_Parthian Inscriptional Parthian | |
273 Javanese Javanese | |
274 Kaithi Kaithi | |
275 Kannada Kannada | 261 Kannada Kannada |
276 Katakana Katakana | 262 Katakana Katakana |
277 Kayah_Li Kayah Li | 263 Kayah_Li Kayah Li |
278 Kharoshthi Kharoshthi | 264 Kharoshthi Kharoshthi |
279 Khmer Khmer | 265 Khmer Khmer |
280 Lao Lao | 266 Lao Lao |
281 Latin Latin | 267 Latin Latin |
282 Lepcha Lepcha | 268 Lepcha Lepcha |
283 Limbu Limbu | 269 Limbu Limbu |
284 Linear_B Linear B | 270 Linear_B Linear B |
285 Lycian Lycian | 271 Lycian Lycian |
286 Lydian Lydian | 272 Lydian Lydian |
287 Malayalam Malayalam | 273 Malayalam Malayalam |
288 Mandaic Mandaic | |
289 Meetei_Mayek Meetei Mayek | |
290 Meroitic_Cursive Meroitic Cursive | |
291 Meroitic_Hieroglyphs Meroitic Hieroglyphs | |
292 Miao Miao | |
293 Mongolian Mongolian | 274 Mongolian Mongolian |
294 Myanmar Myanmar | 275 Myanmar Myanmar |
295 New_Tai_Lue New Tai Lue (aka Simplified Tai Lue) | 276 New_Tai_Lue New Tai Lue (aka Simplified Tai Lue) |
296 Nko Nko | 277 Nko Nko |
297 Ogham Ogham | 278 Ogham Ogham |
298 Ol_Chiki Ol Chiki | 279 Ol_Chiki Ol Chiki |
299 Old_Italic Old Italic | 280 Old_Italic Old Italic |
300 Old_Persian Old Persian | 281 Old_Persian Old Persian |
301 Old_South_Arabian Old South Arabian | |
302 Old_Turkic Old Turkic | |
303 Oriya Oriya | 282 Oriya Oriya |
304 Osmanya Osmanya | 283 Osmanya Osmanya |
305 Phags_Pa 'Phags Pa | 284 Phags_Pa 'Phags Pa |
306 Phoenician Phoenician | 285 Phoenician Phoenician |
307 Rejang Rejang | 286 Rejang Rejang |
308 Runic Runic | 287 Runic Runic |
309 Saurashtra Saurashtra | 288 Saurashtra Saurashtra |
310 Sharada Sharada | |
311 Shavian Shavian | 289 Shavian Shavian |
312 Sinhala Sinhala | 290 Sinhala Sinhala |
313 Sora_Sompeng Sora Sompeng | |
314 Sundanese Sundanese | 291 Sundanese Sundanese |
315 Syloti_Nagri Syloti Nagri | 292 Syloti_Nagri Syloti Nagri |
316 Syriac Syriac | 293 Syriac Syriac |
317 Tagalog Tagalog | 294 Tagalog Tagalog |
318 Tagbanwa Tagbanwa | 295 Tagbanwa Tagbanwa |
319 Tai_Le Tai Le | 296 Tai_Le Tai Le |
320 Tai_Tham Tai Tham | |
321 Tai_Viet Tai Viet | |
322 Takri Takri | |
323 Tamil Tamil | 297 Tamil Tamil |
324 Telugu Telugu | 298 Telugu Telugu |
325 Thaana Thaana | 299 Thaana Thaana |
326 Thai Thai | 300 Thai Thai |
327 Tibetan Tibetan | 301 Tibetan Tibetan |
328 Tifinagh Tifinagh | 302 Tifinagh Tifinagh |
329 Ugaritic Ugaritic | 303 Ugaritic Ugaritic |
330 Vai Vai | 304 Vai Vai |
331 Yi Yi | 305 Yi Yi |
332 | 306 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 (*SKIP) NOT SUPPORTED | 364 (*SKIP) NOT SUPPORTED |
391 (*THEN) NOT SUPPORTED | 365 (*THEN) NOT SUPPORTED |
392 (*ANY) set newline convention NOT SUPPORTED | 366 (*ANY) set newline convention NOT SUPPORTED |
393 (*ANYCRLF) NOT SUPPORTED | 367 (*ANYCRLF) NOT SUPPORTED |
394 (*CR) NOT SUPPORTED | 368 (*CR) NOT SUPPORTED |
395 (*CRLF) NOT SUPPORTED | 369 (*CRLF) NOT SUPPORTED |
396 (*LF) NOT SUPPORTED | 370 (*LF) NOT SUPPORTED |
397 (*BSR_ANYCRLF) set \R convention NOT SUPPORTED pcre | 371 (*BSR_ANYCRLF) set \R convention NOT SUPPORTED pcre |
398 (*BSR_UNICODE) NOT SUPPORTED pcre | 372 (*BSR_UNICODE) NOT SUPPORTED pcre |
399 | 373 |
OLD | NEW |