Is there a way to find a match when the pattern /(\sclassName|^className)/ is met in CSS selection? One hypothetical approach could be:
[class(^|\s)='className'] {
font-size: 5000px;
}
Although I found a helpful resource on CSS Attribute Selectors titled The Skinny on CSS Attribute Selectors, it doesn't cover this specific scenario.
I am specifically looking to only match instances of "icon-" in two examples, excluding the third one.
In the first example, you can achieve this with [class^='icon-]
<div class='icon-something another-class'>
In the second example, you can use [class~='icon-']
. However, note that this won't match if 'icon-' appears at the start of the class string:
<div class='another-class icon-something'>
To avoid matching instances like -icon within strings, the *=` method or |=` method may be more suitable:
<div class='another-icon-class another-class'>