I\'d like to parce a CSS file and add before every CSS selector another selector.
From:
p{margin:0 0 10px;}
.lead{margin-bottom:20px;font-size:21px;font-
Faced a similar problem and used the following to extract only CSS selectors and directives without comments and media queries:
/^(?!.*@media)[\t ]*([a-zA-Z#.:*\[][^{\/]*\s*){[\s\S]*?}/
Example: https://regex101.com/r/JmjthP/5
I'm sure it's missing some edge-cases but seems to be working for me.
See this question: Ruby RegExp - Match all CSS selectors and directives