let say that in our websites we can have urls like:
http://domainame.com/dir/one-simple-name.html
https://dmainame.com/mail/send.php
https://dmainame.com/mail/read
etc..
So i would like to retrieve
dir/one-simple-name
mail/send
mail/read
Whats the best way to achieve it?
Everybody stand back! I know regular expressions! Try this one:
var my_location = window.location.toString().match(/\/\/[^\/]+\/([^\.]+)/)[1];
I would recommend doing this by,
var url = "https://www.somegoodwebsite.com/happy/ending/results/index.html";
console.log(url.replace(/^.*\/\/[^\/]+/, '') );
;
Result:
happy/ending/results/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With