0

I want to use regular expression to clean-up some CSS files.

I used a Friebug add-on, CSS Usage, to analyse some CSS from a jquery demo. Exporting the files, this add-on places 'UNUSED' at the front of a declaration and rule. Below is a sample of the output.

html #demo-config-menu li a:link,
UNUSED* html #demo-config-menu li a:visited {
 padding:1px 8px 2px;
}   

UNUSED#demo-config-menu li a:active,
#demo-config-menu li a:hover {
 background-color:#f6f6f6;
}

UNUSED#demo-config-menu h4 {
 font-size:13px; color:#666; font-weight:normal; border:0; padding-left:18px;
} 

New to regular expressions, I have tried in vain to come up with search parameters for what I want.

  1. a way to search compound selectors for instances of UNUSED and the selector that follows, be it the first or second selector within a CSS rule (as in first two code samples);
  2. search for a complete declaration and rule as in the last code example

I have looked at tutorial on youtube and other sources. I can have success with anything up to and before ' {' but can not the search parameters to work beyond that.

Anyone have suggestions?

2
Contributors
2
Replies
6
Views
4 Years
Discussion Span
Last Post by dwlamb
0

Can you show what the output should be? And what tool are you using to for the replacements?

Something like /UNUSED([^,{]+)/ could work.

0

By and large, I don't want replacements. I merely wish to remove the selectors prefaced with UNUSED and for the declarations that are singular, strip the entire declaration and rule from the CSS.

So, based on the code examples provided, I need search paramets that will go something like ", UNUSED [everything to next]," "UNUSED [everything to next]," "UNUSED [everything to space {] but leave the space {" "UNUSED [everything to ]}\n"
I know those are not appropriate syntax. Just My pseudo-code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.