I gave out a bit of duff information in my last post. Thanks Rasmus!
The code should have been:string css = @".class1{color:pink;}.class2{color:blue;}";string patt = @".[-]?[_a-zA-Z][_a-zA-Z0-9-]|[^\0-\177]\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\[^\n\r\f0-9a-f]*";MatchCollection arr = Regex.Matches(css, patt);}The "arr" Collection will contain all the class names found in the input string. arr.Count will be the number of matches, and it can be indexed like so: arr[0].Value etc. etc.Sorry about that :)
1 min read
Updated Answer to CSS Regex Question
Paul Kinlan
Lead of Chrome DevRel
Stay in the loop.
I'm trialing a newsletter. Join for monthly insights into web dev, Chrome, and the open web.