Thread: Regex examples
View Single Post
Old 09-26-2012, 03:58 AM   #148
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
A quick and dirty solution would be:

Find:([[:upper:]]{2,})(.*?)</p>
Replace:<i>\L\1\E</i>\2</p>

This regular expression searches for uppercase words with at least two uppercase letters and will convert them to lower case italics. (For other case transformation examples see my other post).

Since this expression will only match one uppercase word per paragraph, you'll have to run it repeatedly if your paragraphs contain multiple uppercase words.
Theoretically, it might also miss some uppercase words or match more than one paragraph. I.e. don't use it with Replace All.

If this regular expression actually works for you, please do me a favor and upload a fewer books.
Doitsu is offline   Reply With Quote