'ello all.
I am trying to retrieve the following from a given set of URLs
http://www.website.com/subdir/website.php/var1/var2 http://www.website.com/subdir/website.php http://www.website.com/website.php/var1/var2 https://www.website.com/subdir/website.php/var1/var2 https://www.website.com/subdir/ https://www.website.com/subdir Basically everything before /filename.php
I had been using a valid regex, but made some changes to the site and now it's broken. I can't seem to get a valid regex concocted. Could someone please help?
var URL = window.location.href.match('(.*)\/([\w\.]+php)?'); var stuffIwant = URL[1];
TIA!
🙂
Got it worked out with this:
var URL = window.location.href; var arr = /^(.*)\/[\w]+\.(.*)$/.exec(URL); var stuffIwant = arr[1];
Thanks anyways.