daniloprates daniloprates - 4 months ago 25
CSS Question

CSS selector regex anything in between

I'm creating the following elements:

.dh-tl-tl {}
.dh-tl-tr {}
.dh-tl-br {}
.dh-tl-bl {}

.dh-tr-tl {}
...

.dh-br-tl {}
...

.dh-bl-tl {}
...


Is there a way I could get a CSS selector to get the 4 items in each group?

e.g.

[class=(?<=.dh-)(.*)(?=-bl)] {}

Answer

You could use the ^= ('starts with') and $= ('ends with') attribute selectors.

[class^="dh-"][class$="-bl"]{}