In my Website i want to use the german letter ß, which only exists as a lowercase letter. Though i want all my headlines to be shown in uppercase letters (capitalize), i use font-transform: uppercase
. But that replaces the ß letter with a uppercase SS, which is not wanted due to certain design and programming features.
So i was thinking about a preg_replace_callback
, that changes all letters in the headlines in my HTML code to their uppercase letters.
$content = preg_replace_callback('/(<h\d>)(.*)(<\/h\d>)/', function($matches) {
return $matches[1] . mb_strtoupper($matches[2], 'UTF-8') . $matches[3];
}, $content);
That works well on headings with no special attributes or nested links etc. As i'm a total newbie in regular expressions i don't know how to write those.
Basically <h2 class="heading-italic"><a href="http://www.google.de">Google</a></h2>
should become to <h2 class="heading-italic"><a href="http://www.google.de">GOOGLE</a></h2>
How would my regular expression look, that is also catching headings with attributes and also (multiple) nested elements?