I know my question might look like a duplication for this question, but its not
I am trying to match a class name inside html text that comes from the
This may not be a solution for you, but if you aren't set on using a full regex match, you could do (assuming your examples are representative of the data you will be parsing) :
function hasTheClass(html_string, classname) {
//!!~ turns -1 into false, and anything else into true.
return !!~html_string.split("=")[1].split(/[\'\"]/)[1].split(" ").indexOf(classname);
}
hasTheClass("", 'b'); //returns true