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_m
This regex:
/(\w+)?(\s*>\s*)?(#\w+)?\s*(\.\w+)?\s*{/gm
will match any of the following:
p.my_class{} p.thisclas45{} .simple_class{} tag#id.class{} tag > #id{}
You can play around with it, on RegExr, here.