remove hostname and port from url using regular expression
html, javascript, regex
Solution
To javascript you can use this code:
var URL = "http://localhost:7001/www.facebook.com";
var newURL = URL.replace (/^[a-z]{4,5}\:\/{2}[a-z]{1,}\:[0-9]{1,4}.(.*)/, '$1'); // http or https
alert (newURL);
Look at this code in action Here
Regards, Victor
Problem
I am trying to remove ``` http://localhost:7001/ ``` part from ``` http://localhost:7001/www.facebook.com ``` to get the output as ``` www.facebook.com ``` what is the regular expression that i can use to achieve this exact pattern?