Quick Start
Tutorial
Search & Replace
Tools & Languages
Examples
Reference
Replacement Reference
Introduction
Table of Contents
Characters
Matched Text & Backreferences
Case Conversion
Context
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
RegexBuddy—Better than a regular expression reference!

Replacement Strings Reference: Context

FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE2 PHP Delphi R Ruby std::regex Boost Tcl Oracle XPath
Match Context \` (backslash backtick) Insert the part of the subject string to the left of the regex match Replacing b with \` in abc yields aac YESnononononononoerrornononoYESnoYESnonononoerror
Match Context $` (dollar backtick) Insert the part of the subject string to the left of the regex match Replacing b with $` in abc yields aac YESnoYESYESYESYESerrorerrornoYES10.45noYESnonodefaultall
default
nonoerror
Match Context $PREMATCH and ${^PREMATCH} Insert the part of the subject string to the left of the regex match Replacing b with $PREMATCH in abc yields aac nonononoerrornoerrorerrornoerrorerrornononononoall
default
1.42
nonoerror
Match Context \' (backslash quote) Insert the part of the subject string to the right of the regex match Replacing b with \' in abc yields acc YESnononononononoerrornononoYESnoYESnonononoerror
Match Context $' (dollar quote) Insert the part of the subject string to the right of the regex match Replacing b with $' in abc yields acc YESnoYESYESYESYESerrorerrornoYES10.45noYESnonodefaultall
default
nonoerror
Match Context $POSTMATCH and ${^POSTMATCH} Insert the part of the subject string to the right of the regex match Replacing b with $POSTMATCH in abc yields acc nonononoerrornoerrorerrornoerrorerrornononononoall
default
1.42
nonoerror
Match Context $_ Insert the whole subject string Replacing b with $_ in abc yields aabcc YESnonoYESerrorYESerrorerrornoerror10.45noYESnonononononoerror
FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE2 PHP Delphi R Ruby std::regex Boost Tcl Oracle XPath