treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Selecting css properties AND curly brackets from CSS file in Komodo Edit

  • 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

    Hence, I need to select everything within and including the curly brackets, and then deleting them.

    Thanks in advance.

  • Open the Find dialog

    Check the "regex" checkbox

    This regex will find everything inside matching curly braces, and the braces themselves:

    \{[^\}]*\}

    If you want to simply delete everything, you can use the Replace dialog instead, and replace the matches with an empty string.

    You can precede the regex with the class name to find a specific block, e.g.,

    \.template\{[^\}]*\}

    ...though this will match the .template part also.

  • Thank you so much, Traq. I will try this ASAP.

    :D


    Yep, works like a charm. Thanks again.

  • Traq, let me see if I understand correctly:

    this: \{ finds the opening curly bracket

    this: ^ finds the beginning of a string.

    this: \} finds the closing curly bracket.

    this: * finds ANY character

    this: \} finds a closing curly bracket, again.

    I am a bit confused about the square brackets. What are those for?

    Thank you again.

  • not quite:

    \{ opening curly bracket

    [...] defines a character class (a group of characters to match against)

    ^ inside a character class, this means not

    \} closing curly bracket
    (therefore, ^\} means anything except a closing curly bracket)

    * means zero or more of the previous

    \} closing curly bracket.

    Therefore, you're searching for an opening curly bracket, followed by zero or more characters that are not closing brackets (i.e., the block contents), followed by a closing curly bracket.

  • Whooooa, I was WAY off. Thank you SO much for your explanation.

  • no problem, glad I could help.

    (BTW, ^ is indeed a "start" anchor, but only at the beginning of a pattern.)