I was wondering is there way to do something like regex replace in css file?
For example: i have lot of selectors like these:
#div_23
#div_45
#div_8
Let’s say that i cant use classes to add styling, is there way to do something like this in CSS file:
#div_[0-9] {background:#000000}
You can partly match attributes (css2.1 doc / css3 doc) – note however that these rules are rather slow. Especially in your case, where you have to use ultra-slow attribute selectors to match ids which would be blazing fast when using
#.I prefer using hyphenated Ids and classes, I find them more readable and this way you can use the following matcher:
Applied to your case:
would all match
However, CSS3 provides the following attribute selector (which is supported in all major browsers) which would suit your case perfectly:
so you could write:
to match