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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | YES | no | no | no | no | 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 | YES | error | YES | error | no | YES | no | YES | YES | 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 | error | error | error | no | no | no | no | no | error | no | no | no | all default 1.42–1.85 | 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 | YES | no | no | no | no | 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 | YES | error | YES | error | no | YES | no | YES | YES | 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 | error | error | error | no | no | no | no | no | error | no | no | no | all default 1.42–1.85 | no | no | error |
Match Context | \_ | Insert the whole subject string | Replacing b with \_ in abc yields aabcc | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | error |
Match Context | $_ | Insert the whole subject string | Replacing b with $_ in abc yields aabcc | YES | YES | error | error | error | no | YES | no | no | YES | error | no | no | no | no | no | no | error |
Case Conversion | \U0 and \U1 through \U99 | Insert the whole regex match or the 1st through 99th backreference with all letters in the matched text converted to uppercase. | Replacing .+ with \U0 in HeLlO WoRlD yields HELLO WORLD | YES | no | no | no | no | no | YES | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error |
Case Conversion | \L0 and \L1 through \L99 | Insert the whole regex match or the 1st through 99th backreference with all letters in the matched text converted to lowercase. | Replacing .+ with \L0 in HeLlO WoRlD yields hello world | YES | no | no | no | no | no | YES | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error |
Case Conversion | \F0 and \F1 through \F99 | Insert the whole regex match or the 1st through 99th backreference with the first letter in the matched text converted to uppercase and the remaining letters converted to lowercase. | Replacing .+ with \F0 in HeLlO WoRlD yields Hello world | YES | no | no | no | extended error | no | YES | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error |
Case Conversion | \I0 and \I1 through \I99 | Insert the whole regex match or the 1st through 99th backreference with the first letter of each word in the matched text converted to uppercase and the remaining letters converted to lowercase. | Replacing .+ with \I0 in HeLlO WoRlD yields Hello World | YES | no | no | no | extended error | no | YES | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error |
Case Conversion | All literal text and all text inserted by replacement text tokens after | up to the next or is converted to uppercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO WoRlD yields HELLO CRUEL WoRlD | no | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | all default | no | no | error | |
Case Conversion | All literal text and all text inserted by replacement text tokens after | up to the next or is converted to lowercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO WoRlD yields hello cruel WoRlD | no | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | all default | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to uppercase.Replacing (\w+) (\w+) with $1 cRuEl $2 in hElLo wOrLd yields HElLO CRuEl WOrLd | no | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | all default | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to lowercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO WoRlD yields heLlO crUeL woRlD | no | no | no | YES | extended | no | no | no | no | no | no | 3.7–3.10 error | no | no | all default | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to uppercase and the following characters up to the next or are converted to lowercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO wOrLd yields Hello Cruel WOrLd | no | no | no | YES | no | no | no | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to lowercase and the following characters up to the next or are converted to uppercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO WoRlD yields hELLO cRUEL woRlD | no | no | no | YES | no | no | no | no | no | no | no | 3.7–3.10 error | no | no | no | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to uppercase and the following characters up to the next or are converted to lowercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO wOrLd yields Hello Cruel WOrLd | no | no | no | no | no | no | no | no | no | no | no | 3.7–3.10 error | no | no | all default | no | no | error | |
Case Conversion | The first character after | that is inserted into the replacement text as a literal or by a token is converted to lowercase and the following characters up to the next or are converted to uppercase.Replacing (\w+) (\w+) with $1 CrUeL $2 in HeLlO WoRlD yields hELLO cRUEL woRlD | no | no | no | no | no | no | no | no | no | no | no | 3.7–3.10 error | 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/refreplacecase.html
Page last updated: 16 August 2024
Site last updated: 29 August 2024
Copyright © 2003-2024 Jan Goyvaerts. All rights reserved.