Skip to content Skip to sidebar Skip to footer

Javascript Regex Url Matching

I have this so far: chrome.tabs.getSelected(null, function(tab) { var title = tab.title; var btn = ' ' +

Solution 1:

Solution 2:

Remove the quotes. Opera DargonFly gives me:

>>> 'http://www.example.com/version.php'.match(/^http:\/\/www\.example.com\/version\.php/i) 
[object Array]

Solution 3:

Solution 4:

match() should take a RegExp object as argument, not a string. You could probably just remove the single quotes '' from around the expression to make it work. For future reference, you should also escape the periods . in the expression (as it is they will match any single character), and insert a ^ in the beginning to only allow this match in the beginning of the URL.

Post a Comment for "Javascript Regex Url Matching"