jquery - remove duplicate forward slashes from the URL -
jquery - remove duplicate forward slashes from the URL -
how can remove duplicate forwards slashes url, maintain // comes after http: url not break.
http://localhost//example/author/admin/// should be
http://localhost/example/author/admin/ i'm trying this, remove lastly slash. want remove double
abc = 'http://localhost//example/author/admin///'; clean_url = abc.replace(/\/$/,''); alert(clean_url); the next checks 3 slashes.
clean_url = abc.replace("///", ""); alert(clean_url); i want remove duplicate slashes.
you can use:
abc.replace(/([^:]\/)\/+/g, "$1"); working demo
update: already answered halcyon
jquery regex
Comments
Post a Comment