Hi I have a string that can be one of the following, or none, and I'm trying to test to see if one of two class names exists in the string.
<span class="italic bold">beatae</span>
<span class="bold italic">beatae</span>
<span class="bold">beatae</span>
<span class="italic">beatae</span>
A successful match should mean the string is a complete span tag with one of those two class names on it. Ideally I'd like string.match to return the class names (italic, bold, or both) if possible.
The most related post I found on here is this: Need Regexp for classname replace I tried adapting the regex to fit my needs but I'm missing something.
This is what I have so far:
/^<span class="(bold|italic)">[^<]*<\/span>$/i
But I always get null for matches. Thanks in advance!
Edit: It's an actual string in Javascript, not a DOM node, so its equivalent to;
var mystring = '<span class="bold italic">beatea</span>';
var matches = mystring.match( /regex/ );