I am working on removing all of the css attributes in a stylesheet without removing the selector.
For example I want to take this:
.format-chat .chat .chat-timestamp {
color: #722d19;
float: right;
font-size: 12px;
font-weight: normal;
margin: 5px 10px 0;
}
And turn it into this:
.format-chat .chat .chat-timestamp {
}
Since I am working with several thousand lines of CSS it would be nice to do somthing like this in one action, with a simple find and replace. In this case I want to find all text between curly brackets { }
.
To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).
Or, if you want to find and replace text in a number of files at once, press Command + Shift + F or Control + Shift + H to open Sublime Text's Find in Files tool that can search and replace across as many files as you have open or select from its menu.
To use regular expressions in Sublime Text, first activate them in the corresponding search panel by clicking on the available buttons or using keyboard shortcuts. If you don't activate regular expressions before performing a search, the search terms will be interpreted literally.
You can simply use the following regex to find everything inside {
and }
:
\{[^}]*\}
and replace with literal {}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With