How to evaluate the following expression in jQuery without eval()?
I have the following code that does开发者_如何学运维n't seem to be OK in context of jQuery:
jQuery.expr[ ":" ].containsNoCase = function( el, i, m ) {
var search = m[ 3 ];
if( !search ) return false;
return eval( "/" + search + "/i" ).test( jQuery( el ).text() );
};
Is there any other way to return result?
I believe you want
new RegExp(search, "i").test(jQuery(el).text());
精彩评论