Thread: Regex examples
View Single Post
Old 07-28-2013, 01:23 PM   #270
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,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
I'm sure that there's a more elegant solution, but the following simple regex should work:

Find: ([[:upper:]]{1,})([[:lower:]]+)
Replace: \1<small>\U\2\E</small>

Since this simple regex will find title case strings everywhere, you can't use it with Replace All, though.

To replace two consecutive title case words use the following regex:

Find: ([[:upper:]]{1,})([[:lower:]]+) ([[:upper:]]{1,})([[:lower:]]+)
Replace: \1<small>\U\2\E</small> \3<small>\U\4\E</small>

Last edited by Doitsu; 07-28-2013 at 01:50 PM.
Doitsu is offline   Reply With Quote