Reputation: 10839
Well i have a little problem but really strange.
So basically i analyzed URL represented by a string. The only thing i want to check is if this URL contains 'chrome-extension://'
So basically i've tried to escape these caracter like that but it still didn't work...
if(!URL.match(/(chrome\-extension\:\/\/)/i))
Upvotes: 1
Views: 266
Reputation: 19573
This'll work...
var url = "chrome-extension://etc";
alert("match: " + url.match(/^chrome-extension:\/\//));
Check out jsfiddle.
Upvotes: 0
Reputation: 31508
Alternatively:
if (URL.indexOf('chrome-extension://') < 0) {
// No match
}
Upvotes: 4
Reputation: 49
String functions will be much faster than regex with such small things:
if(URL.substr(0,19) != "chrome-extension://")
Upvotes: 2