Reputation: 231
I am developing an application and want to be able to grab only the resource from the URL so I have written a regular expression, but it doesn't seem to be working and I get an uncaught type error. Can anyone help with this?
var link = document.location;
var res = link.match(/\/.*php/g);
Upvotes: 1
Views: 99
Reputation: 321
The problem is that link
is not a string, so it doesn't have the match()
property.
try:
var link = document.location.toString();
var res = link.match(/\/.*php/g);
Upvotes: 4