Let's say I have the following CSS. I need a regular expression that grabs entire declaration blocks (selector, opening bracket, contents, closing bracket) that do not have the folowing colors in them: #f518e2 and #22f1e6
.foo{
color: #f518e2;
box-spacing: border-box;
}
#bar{
color: #e4e4e4;
box-spacing: border-box;
}
biz.baz{
background: #22f1e6;
font-size: 30px;
}
So in this case, I would want to grab:
#bar{
color: #e4e4e4;
box-spacing: border-box;
}
Assumptions:
- There are hundreds of selectors in the file
- The syntax is always valid CSS, but spacing, new lines, and use of semi-colons is inconsistent. For example:
#bar{ color: #e4e4e4;
box-spacing: border-box; }biz.baz
{
background: #22f1e6;
font-size: 30px; }
I've tried something like this: /\w*[#.]?\w+\s*{[^\{\}]+}/g which selects entire declaration blocks, but when it comes to weeding out the ones with #f518e2 and #22f1e6 it's a little beyond what I know about regex.