Given a series of URLs
http://www.anydotcom.com/myfolder/some-url.html http://www.anydotcom.com/myfolder2/index.html# http://www.anydotcom.com/myfolder3/index.html?someParam=aValue http://www.anydotcom.com/foldername/index.html?someParam=anotherValueFirst, how could I strip anything off the end of the URL so that I end up with
http://www.anydotcom.com/myfolder/some-url.html http://www.anydotcom.com/myfolder2/index.html http://www.anydotcom.com/myfolder3/index.html http://www.anydotcom.com/foldername/index.htmlor, ideally, I would like it to return
/myfolder/some-url.html /myfolder2/index.html /myfolder3/index.html /foldername/index.htmlI've tried
var thisUrl = "" + window.location; var myRegExp = new RegExp("([^(\?#)]*)"); thisUrl = myRegExp.exec(thisUrl);
but this returns
http://www.anydotcom.com/foldername/index.html,http://www.anydotcom.com/foldername/index.html
and I don't quite understand why.
I appreciate any help here!