I'd like to make .search() case insensitive for a variable I've entered into it. From the documentation on W3 it appears I can only hard code case insensitive searches. The example on W3 goes:
var str = "Mr. Blue has a blue house";
var n = str.search(/blue/i);
My code looks like:
var searchTerm = $("input").val();
var source = $("#page5").html();
var found = source.search(searchTerm);
If I were to code it like the W3 example then the .search() command would look like:
var found = source.search(/searchTerm/i);
However, when I do that it appears to attempt to search for the literal text of "searchTerm" instead of the value within the variable searchTerm. Is there a way to use the case insensitivity on the search method while inserting a variable into it?