Skip to content

Commit

Permalink
Fix regex doc describing hexadecimal escape characters (#10009)
Browse files Browse the repository at this point in the history
Fixes a documentation error found while diagnosing a hex regex pattern question.

The hex escape sequence only specifies a single character (not a single byte). So this means it can only be used to match ASCII characters (code-points 0-127) and not all UTF-8 characters. This is the same as for octal escape sequences. Also, the example provided for hex in the documentation has been corrected to use a valid ASCII character.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Mike Wilson (https://github.com/hyperbolic2346)
  - https://github.com/nvdbaranec

URL: #10009
  • Loading branch information
davidwendt authored Jan 11, 2022
1 parent 88e6a29 commit 25a7485
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/doxygen/regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The details are based on features documented at https://www.regular-expressions.
| Literal character | Any character except `[\^$.⎮?*+()` | All characters except the listed special characters match a single instance of themselves | `a` matches `a` |
| Literal curly braces | `{` and `}` | `{` and `}` are literal characters, unless they are part of a valid regular expression token such as a quantifier `{3}` | `{` matches `{` |
| Backslash escapes a metacharacter | `\` followed by any of `[\^$.⎮?*+(){}` | A backslash escapes special characters to suppress their special meaning | `\*` matches `*` |
| Hexadecimal escape | `\xFF` where `FF` are 2 hexadecimal digits | Matches the character at the specified position in the code page | `\xA9` matches `©` |
| Hexadecimal escape | `\xFF` where `FF` are 2 hexadecimal digits | Matches the character at the specified position in the ASCII table | `\x40` matches `@` |
| Character escape | `\n`, `\r` and `\t` | Match an line-feed (LF) character, carriage return (CR) character and a tab character respectively | `\r\n` matches a Windows CRLF line break |
| Character escape | `\a` | Match the "alert" or "bell" control character (ASCII 0x07) | |
| Character escape | `\f` | Match the form-feed control character (ASCII 0x0C) | |
Expand Down

0 comments on commit 25a7485

Please sign in to comment.