Skip to content

Commit 305e1f9

Browse files
authored
Merge pull request MicrosoftDocs#38 from Microsoft/corob-msft-patch-1-1
Update regular-expressions-cpp.md
2 parents 4178b9f + f9b8dba commit 305e1f9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/standard-library/regular-expressions-cpp.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Zero or more flags may be combined with the grammar to specify the regular expre
211211
|repetition using "{}"||+|+||+|+|
212212
|repetition using "\\{\\}"|+|||+|||
213213
|repetition using '*'|+|+|+|+|+|+|
214-
|repetition using '' and '+'||+|+||+|+|
214+
|repetition using '?' and '+'||+|+||+|+|
215215
|unicode escape sequence|||+||||
216216
|wildcard character|+|+|+|+|+|+|
217217
|word boundary assert|||+||||
@@ -323,18 +323,18 @@ Zero or more flags may be combined with the grammar to specify the regular expre
323323
### Identity Escape
324324
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:
325325

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\*".
327327

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\*".
329329

330330
The set of characters that are allowed in an identity escape depends on the regular expression grammar, as shown in the following table.
331331

332332
|Grammar|Allowed Identity Escape Characters|
333333
|-------------|----------------------------------------|
334-
|`basic`, `grep`|{ '(', ')', '{', '}', '.', '[', '\\', '*', '^', '$' }|
335-
|`extended`, `egrep`|{ '(', ')', '{', '.', '[', '\\', '*', '^', '$', '+', '', '|' }|
334+
|`basic`, `grep`|{ '(', ')', '{', '}', '.', '[', '\\', '\*', '^', '$' }|
335+
|`extended`, `egrep`|{ '(', ')', '{', '.', '[', '\\', '\*', '^', '$', '+', '?', '|' }|
336336
|`awk`|`extended` plus { '"', '/' }|
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.|
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.|
338338

339339
### Individual Character
340340
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
372372
A negative word boundary assert matches if the current position in the target string is not immediately after a *word boundary*.
373373

374374
### 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".
376376

377377
### 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".
379379

380380
### Octal Escape Sequence
381381
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
385385

386386
In `ECMAScript`, the following characters have special meanings:
387387

388-
- ^ $ \ . * + ( ) [ ] { } |
388+
- ^ $ \ . * + ? ( ) [ ] { } |
389389

390390
In `basic` and `grep`, the following characters have special meanings:
391391

392392
- . [ \
393393

394394
Also in `basic` and `grep`, the following characters have special meanings when they are used in a particular context:
395395

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.
397397

398398
- '^' has a special meaning when it is the first character of a regular expression.
399399

400400
- '$' has a special meaning when it is the last character of a regular expression.
401401

402402
In `extended`, `egrep`, and `awk`, the following characters have special meanings:
403403

404-
- . [ \ ( * + { |
404+
- . [ \ ( * + ? { |
405405

406406
Also in `extended`, `egrep`, and `awk`, the following characters have special meanings when they are used in a particular context.
407407

@@ -418,9 +418,9 @@ Zero or more flags may be combined with the grammar to specify the regular expre
418418

419419
Examples:
420420

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".
422422

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.
424424

425425
- "(=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.
426426

@@ -466,7 +466,7 @@ Zero or more flags may be combined with the grammar to specify the regular expre
466466
|"$&"|"&"|The character sequence that matches the entire regular expression (`[match[0].first, match[0].second)`)|
467467
|"$$"||"$"|
468468
||"\\&"|"&"|
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)`)|
470470
|"$'" (dollar sign followed by forward quote)||The character sequence that follows the subsequence that matches the regular expression (`[match.suffix().first, match.suffix().second)`)|
471471
|"$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)`)|
472472
||"\\\n"|"\n"|

0 commit comments

Comments
 (0)