View Single Post
Old 05-23-2012, 09:06 AM   #6
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
The Sigil PCRE library already supports conversion to upper case and lower case with \U, \u, \L and \l back references.

For example:

Find: <p>(.*?)</p>
Replace: <p>\U\1\E</p>
Before:
Code:
<p>This is a test sentence.</p>
After:
Code:
<p>THIS IS A TEST SENTENCE.</p>
Find: <h3>([[:upper:]])([[:upper:]]{2,})
Replace: <h3>\1\L\2
Before:
Code:
<h3>CHAPTER 1</h3>
After:
Code:
<h3>Chapter 1</h3>
Find: <p>(.*?)</p>
Replace: <p>\u\1</p>
Before:
Code:
<p>this is a test sentence.</p>
After:
Code:
<p>This is a test sentence</p>
These back references are also useful for Project Gutenberg texts with all caps text instead of italics. For example:

Find: ([[:upper:]]{2,})
Replace: <i>\L\1\E</i>
Before:
Code:
<p>This should be in ITALICS.</p>
After:
Code:
<p>This should be in <i>italics</i>.</p>

Last edited by Doitsu; 09-26-2012 at 04:03 AM.
Doitsu is offline   Reply With Quote