How can I remove duplicate forward slashes from the a url, but keep the // which comes after http:
so that the URL does not break.
http://localhost//example/author/admin///
should be
http://localhost/example/author/admin/
I'm trying this, but it will remove only the last slash. I want to remove all double
abc = 'http://localhost//example/author/admin///';
clean_url = abc.replace(//$/,'');
alert(clean_url);
The following checks only three slashes.
clean_url = abc.replace("///", "");
alert(clean_url);
I want to remove all the duplicate slashes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…