You know that you can mix style definitions for elements, classes and id's on the same line like following definition demonstrates?
h2, p.red, #attention { color:red }
However, I took the regular expressions of
Cascading Style Sheets (CSS) 1.0-2.1 (case-sensitive) and without much thinking about the expression splitted them up into 3 groups using following definitions:
/TGBegin "Elements"
/TGFindStr = "%[ ^t]++^(["*+,^-0-9:=>@^[^]_a-z|~][ ^t^p"*+,^-0-9:=>@^[^]_a-z|~]+^){"
/TGFindStr = "%[ ^t]++^(["*+,^-0-9:=>@^[^]_a-z|~][ ^t^p"*+,^-0-9:=>@^[^]_a-z|~]+^)/^*[~/{}]++^*/[ ^t^p]++{"
/TGEnd
/TGBegin "Classes"
/TGFindStr = "%[ ^t]++^([a-z]++.[ ^t^p"*+,^-.0-9:=>@^[^]_a-z|~]+^){"
/TGEnd
/TGBegin "Identifiers"
/TGFindStr = "%[ ^t]++^(#[ ^t^p"*+,^-0-9:=>@^[^]_a-z|~]+^){"
/TGEnd
This is definitely not perfect, but maybe enough for your requirements.
Please note that I needed to add
%[ ^t]++ on every expression because otherwise it is impossible with the UltraEdit regular expression engine not supporting lookbehind to avoid a class definition like
.s5 { font-size:18pt }
to be listed in group
Elements (finds only s5) and group
Classes (finds .s5). So the expressions now find only style definitions in CSS files or style blocks.
Further note that a CSS definition like
table.black td { border-style:solid; border-width:1px; border-color:#000000 }
is listed in group
Classes and not in
Elements. I can't really decide on interpreting a CSS definition for a nested element as class definition or as element definition. I prefer classifying a definition for an element inside another element with special style as class definition.