I would like to pull the last class from css rules using Regex in javascript.
The regex rule I'm going to do is start the search from the end of the rule, for example. to .myClass.myOtherClass' and return the first word after the last full stop - so the result will be ".myOtherClass"
Example css rules I need to map:
.myClass{color:red;} .myClass .myOtherClass{color:green;} #something .somethingElse{color:blue;} .something #myIdhere{color:purple;} #myId {color:black} .myClass1, .myClass2{colour:green} .myClass span{colour:purple} .myPseudo:after{}
I can get the rules myself without {} info. Therefore, its regular expression will run each of the rules on its own. e.g. on '.myClass.myOtherClass' yourself. The conclusion from the rules above that I would like to get is that it matches, as shown below:
.myClass .myOtherClass .somethingElse .something no match .myClass2 .myClass .myPseudo
Can anyone help?
source share