I'm struggling to match and keep all CSS rules containing the string 224,13,78
.
Sample input:
h1 {
color: rgb(224,13,78);
}
h1 {
display: block; /* Delete this whole block */
}
#test-color {
color: rgb(224,13,78);
}
.test-position {
position: absolute; /* Delete this whole block */
}
.test-bg-color {
background-color: rgba(224,13,78,0.5);
}
@media ( max-width: 1200px ) {
.test-color {
color: rgb(224,13,78);
}
.test-position {
overflow: hidden; /* Delete this whole block */
}
}
Desired output:
h1 {
color: rgb(224,13,78);
}
#test-color {
color: rgb(224,13,78);
}
.test-bg-color {
background-color: rgba(224,13,78,0.5);
}
@media ( max-width: 1200px ) {
.test-color {
color: rgb(224,13,78);
}
}
Is there a handy regex that solves my problem?
For reference, I found this solution, but it matches the property name, not the value:
Find: \{.*(font-size\:\s*\d+px\;).*\}?
Replace: \{ $1 \}
And also this JavaScript solution that does the same:
What is RegEx to remove css keeping font size
I accept a JavaScript solution too, but PHP is preferable.
Thank you all in advance.