What is a regular expression that can be used to validate a CSS selector, and can do so in a way that a invalid selector halts quickly.
Valid selectors:
EE
#myid
.class
.class.anotherclass
EE .class
EE .class EEE.anotherclass
EE[class="test"]
.class[alt~="test"]
#myid[alt="test"]
EE:hover
EE:first-child
E[lang|="en"]:first-child
EE#test .class>.anotherclass
EE#myid.classshit.anotherclass[class~="test"]:hover
EE#myid.classshit.anotherclass[class="test"]:first-child EE.Xx:hover
Invalid selectors, e.g. contain extra whitespace at the end of the line:
EE:hover EE
EE .class EEE.anotherclass
EE#myid.classshit.anotherclass[class="test"]:first-child EE.Xx:hov 9
EE#myid.classshit.anotherclass[class="test"]:first-child EE.Xx:hov -daf