- This topic is empty.
-
AuthorPosts
-
January 7, 2013 at 4:37 pm #41822
mauferrusca
MemberHow 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
.template1Hence, I need to select everything within and including the curly brackets, and then deleting them.
Thanks in advance.
January 7, 2013 at 8:56 pm #120189__
ParticipantOpen 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.
January 8, 2013 at 9:25 am #120250mauferrusca
MemberThank you so much, Traq. I will try this ASAP.
:D
—
Yep, works like a charm. Thanks again.
January 8, 2013 at 9:37 am #120253mauferrusca
MemberTraq, 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.
January 8, 2013 at 10:13 am #120259__
Participantnot 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.
January 8, 2013 at 10:34 am #120261mauferrusca
MemberWhooooa, I was WAY off. Thank you SO much for your explanation.
January 8, 2013 at 10:33 pm #120275__
Participantno problem, glad I could help.
*(BTW, `^` is indeed a “start” anchor, but only at the beginning of a pattern.)*
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.