This is a simple question that I think.
I am trying to find the appearance of a string in another string using regex in JavaScript, for example:
var content ="Hi, I like your Apartment. Could we schedule a viewing? My phone number is: "; var gent = new RegExp("I like your Apartment. Could we schedule a viewing? My", "g"); if(content.search(gent) != -1){ alert('worked'); }
Does this not work due to the character ? .... I tried to execute it with \ , but that won't work either. Is there any other way to use ? literally instead of a special character?
javascript regex literals
Andrew May 20 '09 at 20:04 2009-05-20 20:04
source share