Quick Start
Tutorial
Tools & Languages
Examples
Reference
Book Reviews
RegexBuddy—Better than a regular expression reference!

Replacement String Characters

FeatureSyntaxDescriptionExample 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 ! nonoYESYESextendednonoYESnononononosedYESnonoerror
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 \! YESYESnonodefaultYESYESnoYESYESYESYESYESdefaultnoYESYESerror
Backslash Trailing backslash A backslash at the end of the replacement string is a literal backslash. Replacing with \ yields \ YESYESerrorerrordefaultYESYESnoYESYESYESerrorYESdefaultYESYESYESerror
Backslash \\ A backslash escapes itself. Replacing with \\ yields \ YESnoYESYESextendedYESYESYESnononoYESYESsedYESYESYESYES
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 $! YESYESerrorerrorerrorYESYESYESYESYESerrorYESYESYESYESYESYESerror
Dollar Trailing dollar A dollar sign at the end of the replacement string is a literal dollar sign. Replacing with $ yields $ YESYESerrorerrorerrorYESYESYESYESYESYESYESYESdefault VC’15–VC’17
sed VC’08–VC’17
YESYESYESerror
Dollar $$ A dollar sign escapes itself. Replacing with $$ yields $ YESYESerrorerrorYESnoYESnoYESYESYESnonodefaultall
default
nonoerror
Dollar \$ A backslash escapes a dollar sign. Replacing with \$ yields $ YESnoYESYESextendedYESYESYESnononononosedYESnonoYES
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 YESnonoYESextendedstringnostringstringnostringstringstringstringYESstringnoerror
Unicode escape \uFFFF where FFFF are 4 hexadecimal digits Inserts a specific Unicode code point. \u00E0 inserts à encoded as U+00E0 only. \u00A9 inserts © YESnostringnoextended errornonostringstringnostringstring1.9 stringstringnostringnoerror
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 © V2nononoextended error7.0.0 stringnostringstringnostringno1.9 stringnonononoerror
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 © YESnonoYESextendednononononononononoYESnonoerror
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 YESnostringYESextendedstringnostringstringnostringYESstringstringYESstringnoerror
Character escape \a Insert the "alert" or "bell" control character (ASCII 0x07) nononoYESextendednonononononoYESnonoYESnonoerror
Character escape \b Insert the "backspace" control character (ASCII 0x08) nononoYESextended errornonononononoYESnononononoerror
Character escape \e Insert the "escape" control character (ASCII 0x1A) nononoYESextendednononononononononoYESnonoerror
Character escape \f Insert the "form feed" control character (ASCII 0x0C) nononoYESextendednonononononoYESnonoYESnonoerror
Character escape \v Insert the "vertical tab" control character (ASCII 0x0B) nonononoextended errornonononononoYESnonoYESnonoerror
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 nononoYESextendednononononononononoYESnonono
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 nononoYESextendednononononononononoYESnonono
NULL escape \0 Insert the NULL character nononoYESextended errornonononononoYESnonoall
default
nonoerror
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 V2nono5.14extendednonononononononononononoerror
Octal escape \10 through \77 Inserts the character at the specified position in the ASCII table \77 inserts ? nononoYESextended errornonononononononononononoerror
Octal escape \100 through \177 Inserts the character at the specified position in the ASCII table \100 inserts @ nononoYESextended errornonononononoYESnononononoerror
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 nononoYESextended errornonononononoYESnononononoerror
Octal escape \400 through \777 Inserts the character at the specified position in the active code page \777 inserts ǿ when using Unicode nononoYESextended errornonononononononononononoerror
Octal escape \01 through \07 Inserts the character at the specified position in the ASCII table \07 inserts the "bell" character nononoYESextended errornonononononoYESnonoall
default
nonoerror
Octal escape \010 through \077 Inserts the character at the specified position in the ASCII table \077 inserts ? nononoYESextended errornonononononoYESnonoall
default
nonoerror
FeatureSyntaxDescriptionExample JGsoft .NET Java Perl PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE Oracle XPath

Make a Donation

Did this website just save you a trip to the bookstore? Please make a donation to support this site, and you'll get a lifetime of advertisement-free access to this site! Credit cards, PayPal, and Bitcoin gladly accepted.

Replacement Reference
Introduction
Table of Contents
Characters
Matched Text & Backreferences
Context & Case Conversion
Conditionals
Regular Expressions Reference
More on This Site
Introduction
Regular Expressions Quick Start
Regular Expressions Tutorial
Replacement Strings Tutorial
Applications and Languages
Regular Expressions Examples
Regular Expressions Reference
Replacement Strings Reference
Book Reviews
Printable PDF
About This Site
RSS Feed & Blog