remove a variable from a link that comes in a url one or many times
<p>i wanted to remove a variable and its value from a<code>href</code> link like suppose the link has <code>quantity=1</code> one time or two times then i want to remove it no matter how many times it comes in that link. what i had in my mind is to use the jquery <code>replace</code> . i made a code .</p>

<pre><code>   var url = i.text.replace('&amp;quantity','');
</code></pre>

<p>where i had the value </p>

<pre><code>"https://example.com?pid=1&amp;quantity=2&amp;quantity=3"
</code></pre>

<p>but if i use <code>replace</code> i wont be able to remove the value of the variable. So what to do so that not only the string <code>&amp;quantity</code> is removed but also the value associated with it is also removed like full <code>&amp;quantity=3</code>. also keeping in mind that <code>quantity</code> and its values are dynamic it can be one time in the link with some other value or two times with some other.</p>
