Thread: Regex examples
View Single Post
Old 08-06-2019, 02:24 AM   #599
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,625
Karma: 3120635
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
About small caps

Quote:
Originally Posted by Tex2002ans View Post
Smallcaps Unicode:

Search: (*UCP)([[:upper:]])([[:upper:]]{2,})
Replace: <span class="smallcaps">\1\L\2\E</span>

Definitely don't Replace All while using this one, as there can be many false positives.

What each part is doing, in plain English:

(*UCP) = This tells PCRE to be "unicode aware". Allows you to get those accented characters, like È.

[[:upper:]] = Grabs the first uppercase character. (Becomes Group 1)

[[:upper:]]{2,} = Grabs the next 2 or more uppercase characters. (Becomes Group 2)

.../...
The above regex works fine.

Maybe it's a little greedy because it also transforms words written in capitals which are included in the head like "DOCTYPE".

Is there a way to make it work strictly within body tags?
roger64 is offline   Reply With Quote