I'm trying to figure out how to match a set of specific classes -
I want to match classes inline AND/OR a (set of) colors only, either on their own or 2 together:
<span class="inline"> should match
<span class="green"> should match
<span class="inline green"> should match
<span class="blue inline"> should match
--
<span class="inline green blue"> should not match (no more than 2 classes)
<span class="green blue"> should not match (two colors - doesn't have inline class)
I've got this at the moment but it's not working:
regex /((inline)?(\s|green|blue|red|yellow))/
Any suggestions? Many thanks
classNameorgetAttribute('class')?var tmpDiv = document.createElement('div'); tmpDiv.innerHTML = htmlString; var spans = tmpDiv.getElementsByTagName('span');, by inserting the spans in a temp div, the markup will be parsed... that's a lot easier than cocking about with regex's, and it's more reliable