Remove all empty values from url string - Javascript jQuery

Javascript examples for jQuery:String

Description

Remove all empty values from url string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> 
      <script type="text/javascript">
    $(function(){//from w w  w  .jav  a2 s  .  c  o m
var s = 'http://localhost/wm/frontend/www/?test=&lol=1&boo=2&r=';
s = s.replace(/\w*=\&/g, '');
s = s.replace(/&\w*=$/g, '');
console.log(s);
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials