I have multiple HTML/CSS sites where I have classes added automatically due to a bug in an earlier version. Therefore my HTML files look currently like this:
<html class=" js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js lang=de><head>
or like this:
<html class=" js cssanimations webkit chrome win js js cssanimations gecko win js js cssanimations webkit chrome win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js" lang="de"><head>
So those “phrases” are repeating:
js cssanimations gecko win js
or:
js cssanimations webkit chrome win js
I would like to write a regex in PHP where I replace those classes with an empty string. Here is what I´ve tried so far but it is not working at all:
private $replaceRegexes = [
'html-class-attributes' => [
'regex' => '/<html.*class=".*".*>/',
'replacement' => '<html lang="de">',
]
];
But /<html.*class=".*".*>/
is not working.
Can someone help me out and let me know the correct regex for deleting the classes inside the <html tag?
Would appreciate any help.
Thanks,
Chris