Replacement Reference |
Introduction |
Table of Contents |
Characters |
Matched Text & Backreferences |
Context & Case Conversion |
Conditionals |
Regular Expressions Reference |
Feature | Syntax | Description | Example | JGsoft | .NET | Java | Perl | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | Oracle | XPath |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Backslash | Backslash followed by any character that does not form a token | A backslash that is followed by any character that does not form a replacement string token in combination with the backslash inserts the escaped character literally. | Replacing with \! yields ! | no | no | YES | YES | extended | no | no | YES | no | no | no | 3.7–3.10 error | no | sed | YES | no | no | error |
Backslash | A backslash that does not form a token | A backslash that is not part of a replacement string token is a literal backslash. | Replacing with \! yields \! | YES | YES | no | no | default | YES | YES | no | YES | YES | YES | YES | YES | default | no | YES | YES | error |
Backslash | Trailing backslash | A backslash at the end of the replacement string is a literal backslash. | Replacing with \ yields \ | YES | YES | error | error | default | YES | YES | no | YES | YES | YES | error | YES | default | YES | YES | YES | error |
Backslash | \\ | A backslash escapes itself. | Replacing with \\ yields \ | YES | no | YES | YES | extended | YES | YES | YES | no | no | no | YES | YES | sed | YES | YES | YES | YES |
Dollar | A dollar that does not form a token | A dollar sign that does not form a replacement string token is a literal dollar sign. | Replacing with $! yields $! | YES | YES | error | error | error | YES | YES | YES | YES | YES | error | YES | YES | YES | YES | YES | YES | error |
Dollar | Trailing dollar | A dollar sign at the end of the replacement string is a literal dollar sign. | Replacing with $ yields $ | YES | YES | error | error | error | YES | YES | YES | YES | YES | 2–4 | YES | YES | default VC’15–VC’22 sed VC’08–VC’22 | YES | YES | YES | error |
Dollar | $$ | A dollar sign escapes itself. | Replacing with $$ yields $ | YES | YES | error | error | YES | no | YES | no | YES | YES | YES | no | no | default | all default | no | no | error |
Dollar | \$ | A backslash escapes a dollar sign. | Replacing with \$ yields $ | YES | no | YES | YES | extended | YES | YES | YES | no | no | no | 3.7–3.10 error | no | sed | YES | no | no | YES |
Hexadecimal escape | \xFF where FF are 2 hexadecimal digits | Inserts the character at the specified position in the code page | \xA9 inserts © when using the Latin-1 code page | YES | no | no | YES | extended | string | no | string | string | no | string | string | string | string | YES | string | no | error |
Unicode escape | \uFFFF where FFFF are 4 hexadecimal digits | Inserts a specific Unicode code point. | \u00E0 inserts à encoded as U+00E0 only. \u00A9 inserts © | YES | no | string | no | extended error | no | no | string | string | no | string | string | 1.9 string | string | no | string | no | error |
Unicode escape | \u{FFFF} where FFFF are 1 to 4 hexadecimal digits | Inserts a specific Unicode code point. | \u{E0} inserts à encoded as U+00E0 only. \u{A9} inserts © | V2 | no | no | no | extended error | 7.0.0 string | no | string | string | no | string | 3.7–3.10 error | 1.9 string | no | no | no | no | error |
Unicode escape | \x{FFFF} where FFFF are 1 to 4 hexadecimal digits | Inserts a specific Unicode code point. | \x{E0} inserts à encoded as U+00E0 only. \x{A9} inserts © | YES | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | YES | no | no | error |
Character escape | \n, \r and \t | Insert an LF character, CR character and a tab character respectively | \r\n inserts a Windows CRLF line break | YES | no | string | YES | extended | string | no | string | string | no | string | YES | string | string | YES | string | no | error |
Character escape | \a | Insert the “alert” or “bell” control character (ASCII 0x07) | no | no | no | YES | extended | no | no | no | no | no | no | YES | no | no | YES | no | no | error | |
Character escape | \b | Insert the “backspace” control character (ASCII 0x08) | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | no | no | no | error | |
Character escape | \e | Insert the “escape” control character (ASCII 0x1B) | no | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | YES | no | no | error | |
Character escape | \f | Insert the “form feed” control character (ASCII 0x0C) | no | no | no | YES | extended | no | no | no | no | no | no | YES | no | no | YES | no | no | error | |
Character escape | \v | Insert the “vertical tab” control character (ASCII 0x0B) | no | no | no | no | extended error | no | no | no | no | no | no | YES | no | no | YES | no | no | error | |
Control character escape | \cA through \cZ | Insert an ASCII character Control+A through Control+Z, equivalent to \x01 through \x1A | \cM\cJ inserts a Windows CRLF line break | no | no | no | YES | extended | no | no | no | no | no | no | no | no | no | YES | no | no | no |
Control character escape | \ca through \cz | Insert an ASCII character Control+A through Control+Z, equivalent to \x01 through \x1A | \cm\cj inserts a Windows CRLF line break | no | no | no | YES | extended | no | no | no | no | no | no | no | no | no | YES | no | no | no |
NULL escape | \0 | Insert the NULL character | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | all default | no | no | error | |
Octal escape | \o{7777} where 7777 is any octal number | Inserts the character at the specified position in the active code page | \o{20254} inserts € when using Unicode | V2 | no | no | 5.14 | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error |
Octal escape | \10 through \77 | Inserts the character at the specified position in the ASCII table | \77 inserts ? | no | no | no | YES | extended error | no | no | no | no | no | no | no | no | no | no | no | no | error |
Octal escape | \100 through \177 | Inserts the character at the specified position in the ASCII table | \100 inserts @ | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | no | no | no | error |
Octal escape | \200 through \377 | Inserts the character at the specified position in the active code page | \377 inserts ÿ when using the Latin-1 code page | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | no | no | no | error |
Octal escape | \400 through \777 | Inserts the character at the specified position in the active code page | \777 inserts ǿ when using Unicode | no | no | no | YES | extended error | no | no | no | no | no | no | no | no | no | no | no | no | error |
Octal escape | \01 through \07 | Inserts the character at the specified position in the ASCII table | \07 inserts the “bell” character | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | all default | no | no | error |
Octal escape | \010 through \077 | Inserts the character at the specified position in the ASCII table | \077 inserts ? | no | no | no | YES | extended error | no | no | no | no | no | no | YES | no | no | all default | no | no | error |
Feature | Syntax | Description | Example | JGsoft | .NET | Java | Perl | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | Oracle | XPath |
| Quick Start | Tutorial | Tools & Languages | Examples | Reference | Book Reviews |
| Introduction | Table of Contents | Characters | Matched Text & Backreferences | Context & Case Conversion | Conditionals | Regular Expressions Reference |
Page URL: https://www.regular-expressions.info/refreplacecharacters.html
Page last updated: 15 March 2024
Site last updated: 06 November 2024
Copyright © 2003-2024 Jan Goyvaerts. All rights reserved.