You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/standard-library/regular-expressions-cpp.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -211,7 +211,7 @@ Zero or more flags may be combined with the grammar to specify the regular expre
211
211
|repetition using "{}"||+|+||+|+|
212
212
|repetition using "\\{\\}"|+|||+|||
213
213
|repetition using '*'|+|+|+|+|+|+|
214
-
|repetition using '' and '+'||+|+||+|+|
214
+
|repetition using '?' and '+'||+|+||+|+|
215
215
|unicode escape sequence|||+||||
216
216
|wildcard character|+|+|+|+|+|+|
217
217
|word boundary assert|||+||||
@@ -323,18 +323,18 @@ Zero or more flags may be combined with the grammar to specify the regular expre
323
323
### Identity Escape
324
324
An identity escape is a backslash followed by a single character. It matches that character. It is required when the character has a special meaning; by using the identity escape, the special meaning is removed. For example:
325
325
326
-
- "a*" matches the target sequence "aaa", but does not match the target sequence "a\*".
326
+
- "a\*" matches the target sequence "aaa", but does not match the target sequence "a\*".
327
327
328
-
- "a\\*" does not match the target sequence "aaa", but matches the target sequence "a\*".
328
+
- "a\\\*" does not match the target sequence "aaa", but matches the target sequence "a\*".
329
329
330
330
The set of characters that are allowed in an identity escape depends on the regular expression grammar, as shown in the following table.
|`ECMAScript`|All characters except those that can be part of an identifier. Typically, this includes letters, digits, '$', '_', and unicode escape sequences. For more information, see the ECMAScript Language Specification.|
337
+
|`ECMAScript`|All characters except those that can be part of an identifier. Typically, this includes letters, digits, '$', '\_', and unicode escape sequences. For more information, see the ECMAScript Language Specification.|
338
338
339
339
### Individual Character
340
340
An individual character in a bracket expression adds that character to the character set that is defined by the bracket expression. Anywhere in a bracket expression except at the beginning, a '^' represents itself.
@@ -372,10 +372,10 @@ Zero or more flags may be combined with the grammar to specify the regular expre
372
372
A negative word boundary assert matches if the current position in the target string is not immediately after a *word boundary*.
373
373
374
374
### Non-capture Group
375
-
A non-capture group marks its contents as a single unit in the regular expression grammar, but does not label the target text. For example, "(a)(:b)*(c) matches the target text "abbc" and associates capture group 1 with the subsequence "a" and capture group 2 with the subsequence "c".
375
+
A non-capture group marks its contents as a single unit in the regular expression grammar, but does not label the target text. For example, "(a)(:b)\*(c)" matches the target text "abbc" and associates capture group 1 with the subsequence "a" and capture group 2 with the subsequence "c".
376
376
377
377
### Non-greedy Repetition
378
-
A non-greedy repetition consumes the shortest subsequence of the target sequence that matches the pattern. A greedy repetition consumes the longest. For example, "(a+)(a*b)" matches the target sequence "aaab". When a non-greedy repetition is used, it associates capture group 1 with the subsequence "a" at the beginning of the target sequence and capture group 2 with the subsequence "aab" at the end of the target sequence. When a greedy match is used, it associates capture group 1 with the subsequence "aaa" and capture group 2 with the subsequence "b".
378
+
A non-greedy repetition consumes the shortest subsequence of the target sequence that matches the pattern. A greedy repetition consumes the longest. For example, "(a+)(a\*b)" matches the target sequence "aaab". When a non-greedy repetition is used, it associates capture group 1 with the subsequence "a" at the beginning of the target sequence and capture group 2 with the subsequence "aab" at the end of the target sequence. When a greedy match is used, it associates capture group 1 with the subsequence "aaa" and capture group 2 with the subsequence "b".
379
379
380
380
### Octal Escape Sequence
381
381
An octal escape sequence is a backslash followed by one, two, or three octal digits (0-7). It matches a character in the target sequence that has the value that is specified by those digits. If all the digits are '0', the sequence is invalid. For example, "\101" matches the target sequence "A" when ASCII character encoding is used.
@@ -385,23 +385,23 @@ Zero or more flags may be combined with the grammar to specify the regular expre
385
385
386
386
In `ECMAScript`, the following characters have special meanings:
387
387
388
-
- ^ $ \ . * + ( ) [] { } |
388
+
- ^ $ \ . * + ? ( ) [] { } |
389
389
390
390
In `basic` and `grep`, the following characters have special meanings:
391
391
392
392
- . [ \
393
393
394
394
Also in `basic` and `grep`, the following characters have special meanings when they are used in a particular context:
395
395
396
-
- '*' has a special meaning in all cases except when it is the first character in a regular expression or the first character that follows an initial '^' in a regular expression, or when it is the first character of a capture group or the first character that follows an initial '^' in a capture group.
396
+
- '\*' has a special meaning in all cases except when it is the first character in a regular expression or the first character that follows an initial '^' in a regular expression, or when it is the first character of a capture group or the first character that follows an initial '^' in a capture group.
397
397
398
398
- '^' has a special meaning when it is the first character of a regular expression.
399
399
400
400
- '$' has a special meaning when it is the last character of a regular expression.
401
401
402
402
In `extended`, `egrep`, and `awk`, the following characters have special meanings:
403
403
404
-
- . [ \ ( * + { |
404
+
- . [ \ ( * + ? { |
405
405
406
406
Also in `extended`, `egrep`, and `awk`, the following characters have special meanings when they are used in a particular context.
407
407
@@ -418,9 +418,9 @@ Zero or more flags may be combined with the grammar to specify the regular expre
418
418
419
419
Examples:
420
420
421
-
- "(=aa)(a*)" matches the target sequence "aaaa" and associates capture group 1 with the subsequence "aaaa".
421
+
- "(=aa)(a\*)" matches the target sequence "aaaa" and associates capture group 1 with the subsequence "aaaa".
422
422
423
-
- "(aa)(a*)" matches the target sequence "aaaa" and associates capture group 1 with the subsequence "aa" at the beginning of the target sequence and capture group 2 with the subsequence "aa" at the end of the target sequence.
423
+
- "(aa)(a\*)" matches the target sequence "aaaa" and associates capture group 1 with the subsequence "aa" at the beginning of the target sequence and capture group 2 with the subsequence "aa" at the end of the target sequence.
424
424
425
425
- "(=aa)(a)|(a)" matches the target sequence "a" and associates capture group 1 with an empty sequence (because the positive assert failed) and capture group 2 with the subsequence "a". It also matches the target sequence "aa" and associates capture group 1 with the subsequence "aa" and capture group 2 with an empty sequence.
426
426
@@ -466,7 +466,7 @@ Zero or more flags may be combined with the grammar to specify the regular expre
466
466
|"$&"|"&"|The character sequence that matches the entire regular expression (`[match[0].first, match[0].second)`)|
467
467
|"$$"||"$"|
468
468
||"\\&"|"&"|
469
-
|"$`" (dollar sign followed by back quote)||The character sequence that precedes the subsequence that matches the regular expression (`[match.prefix().first, match.prefix().second)`)|
469
+
|"$\`" (dollar sign followed by back quote)||The character sequence that precedes the subsequence that matches the regular expression (`[match.prefix().first, match.prefix().second)`)|
470
470
|"$'" (dollar sign followed by forward quote)||The character sequence that follows the subsequence that matches the regular expression (`[match.suffix().first, match.suffix().second)`)|
471
471
|"$n"|"\n"|The character sequence that matches the capture group at position `n`, where `n` is a number between 0 and 9 (`[match[n].first, match[n].second)`)|
0 commit comments