title: Removing or Replacing # (hash) in URL using Regex
body: <p>I'm new to regex and I'm using it in jquery to remove/replace the url but when i triggered an anchortag with <code>href="#"</code> the url will add a <code>#</code> and I'm not able to replace it with my current regex fix to replace the url.</p>
  
  <pre><code>http://localhost:3131/Main/MainPage?a=1221#&amp;ab=&amp;ac=
  </code></pre>
  
  <p>the original link onload is </p>
  
  <pre><code>http://localhost:3131/Main/MainPage?a=1221
  </code></pre>
  
  <p>but after triggering an anchortag with <code>href="#"</code> return, it becomes this:</p>
  
  <pre><code>http://localhost:3131/Main/MainPage?a=1221#
  </code></pre>
  
  <p>and my expected result upon removing the hash(#) in my url is this:</p>
  
  <pre><code>http://localhost:3131/Main/MainPage?a=1221&amp;ab=&amp;ac=
  </code></pre>
  
  <p>heres my function for replacing the url when closing modal windows in jquery</p>
  
  <pre><code>function updateQueryStringParameter(uri, key, value, key1,value1) {
              var re = new RegExp("([?&amp;])" + key + "=.*?(&amp;|$)" + key1 + "=.*?(&amp;|$)", "i");
              var separator = uri.indexOf('?') !== -1 ? "&amp;" : "?";
              if (uri.match(re)) {
                  return uri.replace(re, '$1' + key + "=" + value + '$2' + key1 + "=" + value1 + '$3' );
                  }
              else {
                  return uri + separator + key + "=" + value + separator + key1 + "=" + value1;
                }
            };
  </code></pre>
  
  <p>Hope someone can help me as i am a beginner on using Regular expression specially in jquery.</p>
  
  <p>Thanks!</p>