I am trying to write a regex that matches a valid CSS class name structure. I have this so far:
$pattern = "([A-Za-z]*\.[A-Za-z]+\s*{)";
$regex = preg_match_all($pattern, $html, $matches);
However, a class name can be in the following formats that my regex won't match:
p.my_class{
}
p.thisclas45{
}
These are just some cases, I've looked around to find the rules of how you can name a class in a style block but couldn't find anything. Anyone know where the rules for the class naming conventions are?
Are there any more cases that I need to consider? What regex would you use to match a class name?
I have already narrowed it down to a style block using the PHP DOM Document class.