I'm using the following code to search sub string in a string
mystring.search(new RegExp(substring, 'i'))
Reason why I am using new RegExp
is, I want to search case insensitive. However, when there is a string like
var mystring = '10" stick';
and I want to search 10"
, the code above does not return any result. It's clearly because of new RegExp
and double quote. Is there any particular flag that needs to be passed in new RegExp
? I googled a lot but couldn't find any solution. What am I missing?