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: Case Conversion and Case Folding

FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE2 PHP Delphi R Ruby std::regex Boost Tcl Oracle XPath
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 YES3.7 errornonononononoerrornononoYESnonononononoerror
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 YES3.7 errornonononononoerrornononoYESnonononononoerror
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 YES3.7 errornonononononoerrornoextended errornoYESnonononononoerror
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 YES3.7 errornonononononoerrornoextended errornoYESnonononononoerror
Case Conversion \U All literal text and all text inserted by replacement text tokens after \U up to the next \E or \L is converted to uppercase. Replacing (\w+) (\w+) with \U$1 CrUeL \E$2 in HeLlO WoRlD yields HELLO CRUEL WoRlD no3.7 errornonononononoerrorYESextendednononononoall
default
nonoerror
Case Conversion \L All literal text and all text inserted by replacement text tokens after \L up to the next \E or \U is converted to lowercase. Replacing (\w+) (\w+) with \L$1 CrUeL \E$2 in HeLlO WoRlD yields hello cruel WoRlD no3.7 errornonononononoerrorYESextendednononononoall
default
nonoerror
Case Conversion \u The first character after \u that is inserted into the replacement text as a literal or by a token is converted to uppercase. Replacing (\w+) (\w+) with \u$1 \ucRuEl \u$2 in hElLo wOrLd yields HElLO CRuEl WOrLd no3.7 errornonononononoerrorYESextendednononononoall
default
nonoerror
Case Conversion \l The first character after \l that is inserted into the replacement text as a literal or by a token is converted to lowercase. Replacing (\w+) (\w+) with \l$1 \lCrUeL \l$2 in HeLlO WoRlD yields heLlO crUeL woRlD no3.7 errornonononononoerrorYESextendednononononoall
default
nonoerror
Case Conversion \u\L The first character after \u\L 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 \E or \U are converted to lowercase. Replacing (\w+) (\w+) with \u\L$1 \uCrUeL \E\u$2 in HeLlO wOrLd yields Hello Cruel WOrLd no3.7 errornonononononoerrorYESextended
10.45
nonononononononoerror
Case Conversion \l\U The first character after \l\U 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 \E or \L are converted to uppercase. Replacing (\w+) (\w+) with \l\U$1 \lCrUeL \E\l$2 in HeLlO WoRlD yields hELLO cRUEL woRlD no3.7 errornonononononoerrorYESextended
10.45
nonononononononoerror
Case Conversion \L\u The first character after \L\u 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 \E or \U are converted to lowercase. Replacing (\w+) (\w+) with \L\u$1 \uCrUeL \E\u$2 in HeLlO wOrLd yields Hello Cruel WOrLd no3.7 errornonononononoerrornononononononoall
default
nonoerror
Case Conversion \U\l The first character after \U\l 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 \E or \L are converted to uppercase. Replacing (\w+) (\w+) with \U\l$1 \lCrUeL \E\l$2 in HeLlO WoRlD yields hELLO cRUEL woRlD no3.7 errornonononononoerrornononononononoall
default
nonoerror
Case Folding \F Unicode case folding is applied to all literal text and all text inserted by replacement text tokens after \F up to the next \E, \U, or \L. Case folding converts most characters to lowercase, but some to uppercase or to alternative lowercase characters. Replacing (\w+) (\w+) with \F$1 CrUeL \E$2 in HeLlO WoRlD yields hello cruel WoRlD no3.7 errornonononononoerror5.16extended errornonononononononoerror
Case Folding \u\F The first character after \u\F that is inserted into the replacement text as a literal or by a token is converted to uppercase. Unicode case folding is applied to all following characters up to the next \E, \U, or \L. Replacing (\w+) (\w+) with \u\F$1 \uCrUeL \E\u$2 in HeLlO wOrLd yields Hello Cruel WOrLd no3.7 errornonononononoerror5.16extended errornonononononononoerror
Case Folding \l\F The first character after \l\U that is inserted into the replacement text as a literal or by a token is converted to lowercase. Unicode case folding is applied to all following characters up to the next \E, \U, or \L. Replacing (\w+) (\w+) with \l\F$1 \lCrUeL \E\l$2 in HeLlO WoRlD yields hello cruel woRLD no3.7 errornonononononoerror5.16extended errornonononononononoerror
FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE2 PHP Delphi R Ruby std::regex Boost Tcl Oracle XPath