0

How would one search, within a CSS file and using Komodo Edit, everything inside and including the brackets from every CSS style rule.

I need to end up with a list of CSS classes and IDs erasing all properties from a very large CSS file.

I need to turn this:

.template{
color: #FFF;
}
.template1{
color:red;
}

into this:

.template
.template1

Thanks in advance.

2 Answers 2

2

you could use a regular expression to find every appearance of things between '{' and '}', and then replace them with "nothing". Note that I don't know Komodo Edit, but I'm guessing it is capable of using regular expressions to search / replace text. Sou you'll have to find out how.

the expression could be like this:

{[\w\s:;#]*}

If you don't know regular expressions, here it is a short explanation:

  • { and } match the { and }
  • [] is the group of characters you will look into the brackets, and here goes whatever you need to select.
  • \w matches leters and numbers, and the underscore
  • \s matches white spaces (spaces, tabs, etc)
  • : ; # - directly matches those symbols

just add any other symbols that you may find between the { }, I may forgot some of them.

However, I highly recommend learning regular expressions, they are a powerful tool to achieve exactly what you need.

A nice playground for regexs can be found here , and over here I've put you the regex I suggest for you to play around with it.

One last word: If you need more help with regular expressions, you could go to stackoverflow instead of here. (perhaps they'll even migrate your post, but I'm answering you here).

good luck!

1
  • Thanx Diego. Your answer has pointed me to the correct direction, but I still cannot select EVERY single block of text within curly brackets. Some are selected, some aren't. I guess I'll need to be much more specific (or not, I'll have to test).
    – MauF
    Jan 7, 2013 at 22:22
0

I fiddled around a bit and with this RegEx pattern:

\{[^\}]*\}

I can select everything I needed, including strings such as:

{
background:url("../img/mas.png") no-repeat scroll center top transparent;height:19px;padding:0;position:relative;width:20px;z-index:98;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .