I have some CSS and I'm looking to create a list of all the class names and identifiers. This is what I have:
var TheList = new List<string>();
var Test2 = Regex.Matches(TheCSS, ".-?[_a-zA-Z]+[_a-zA-Z0-9-]*(?=[^}]*\\{)");
foreach(Match m in Test2)
{
TheList.Add(m.Value);
}
The problem is that there are some unwanted elements:
body
:hover
select
input
label
[for
input
[type
'radio
I've tried with several regex expressions that I've found online; this one is the closest but it's not perfect yet. Basically, it needs to include only elements that begin with # and . so as to avoid body and [type and then not include pseudo-selectors like :hover
What do I need to change in the regex to make it work?