Javascript examples for RegExp:Match URL
Remove duplicate forward slashes from the URL via regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w .j ava 2 s . c om var str = 'http://localhost//example/author/admin///'; var clean_url = str.replace(/([^:])(\/\/+)/g, '$1/'); console.log(clean_url); } </script> </head> <body> </body> </html>