Here are a few example SVG files. The content is the same, but the
viewBox
attribute is different for each one.
Normally we are able to select elements by their attribute values in CSS with selectors like
[attribute*="100"]
or
[attribute="STRING" i]
but we can't search based on regex.
But if you need to anyway and you're ready to use JS to do it - can we do it using a tiny bit of JS but keep it in our CSS? Here are two ways you can use JS-in-CSS to write selectors that select elements based on a regex search of an attribute value.
If you know CSS selectors, regex, and can use
test()
in JavaScript, you're all set :D