I\'d like to match when /(\\sclassName|^className)/
is satisfied, but when selecting css. Hypothetically I would use like:
You'll need to use two separate selectors with the same rule. CSS selectors don't really support alternation.
[class^='icon-'], [class*=' icon-'] {
/* ... */
}
div {
color: red;
}
[class^='icon-'], [class*=' icon-'] {
color: green;
}
<div class='icon-something another-class'>should match</div>
<div class='another-class icon-something'>should match</div>
<div class='another-icon-class another-class'>should not match</div>
You can use the following selectors to select any element whose class either starts with "icon-"
or contains " icon-"
(note the space at the start):
[class^="icon-"], [class*=" icon-"] { ... }
JSFiddle demo.