In Javascript, how do I determine if some specific HTML is contained within a larger hunk of HTML?
I tried regex:
var htmlstr;
var reg = /<b class="fl_r">Example</b>/.test(htmlstr);
but it doesn’t work! Console outputs “missing /”. Please, help me fix this.
Regex is a bit of an overkill here. You can just use indexOf like this and not have to worry about escaping things in the string:
jsFiddle to play with it is here: http://jsfiddle.net/jfriend00/86Kny/