| Replacement Reference |
| Introduction |
| Table of Contents |
| Characters |
| Matched Text & Backreferences |
| Case Conversion |
| Context |
| Conditionals |
| Regular Expressions Reference |
| Feature | Syntax | Description | Example | JGsoft | 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 | YES | no | no | no | no | no | no | no | error | no | no | no | YES | no | YES | no | no | no | no | error |
| 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 | YES | no | YES | YES | YES | YES | error | error | no | YES | 10.45 | no | YES | no | no | default | all default | no | no | error |
| 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 | no | no | no | no | error | no | error | error | no | error | error | no | no | no | no | no | all default 1.42 | no | no | error |
| 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 | YES | no | no | no | no | no | no | no | error | no | no | no | YES | no | YES | no | no | no | no | error |
| 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 | YES | no | YES | YES | YES | YES | error | error | no | YES | 10.45 | no | YES | no | no | default | all default | no | no | error |
| 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 | no | no | no | no | error | no | error | error | no | error | error | no | no | no | no | no | all default 1.42 | no | no | error |
| Match Context | $_ | Insert the whole subject string | Replacing b with $_ in abc yields aabcc | YES | no | no | YES | error | YES | error | error | no | error | 10.45 | no | YES | no | no | no | no | no | no | error |
| Feature | Syntax | Description | Example | JGsoft | Python | JavaScript | VBScript | XRegExp | .NET | Java | ICU | RE2 | Perl | PCRE2 | PHP | Delphi | R | Ruby | std::regex | Boost | Tcl | Oracle | XPath |
| Quick Start | Tutorial | Search & Replace | Tools & Languages | Examples | Reference |
| Introduction | Table of Contents | Characters | Matched Text & Backreferences | Case Conversion | Context | Conditionals | Regular Expressions Reference |
Page URL: https://www.regular-expressions.info/refreplacecontext.html
Page last updated: 22 May 2025
Site last updated: 29 October 2025
Copyright © 2003-2025 Jan Goyvaerts. All rights reserved.