Can I pass multiple args (patterns) for Javascript's replace()? If not, any good alternative?
<p>I'm taking the following ex URL <a href="https://support.dev.mysite.com/batch/" rel="nofollow">https://support.dev.mysite.com/batch/</a> and removing everything, but the environment (eg dev). The below code works fine.</p>

<pre><code>var env = endPoint.replace("https://support.", "\n");
var envClean = env.replace(".mysite.com/batch/", "\n");
</code></pre>

<p>I don't like repeating myself. I would like to look for both patterns in the string and remove them all at once. MDN has a good breakdown of replace() here - <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace" rel="nofollow">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace</a> but it doesn't mention anything about multiple arguments.</p>

<p>I've tried this:</p>

<pre><code>var env = endPoint.replace("https://support." &amp;&amp; ".mysite.com/batch/", "\n"); 
</code></pre>

<p>but it just parses the second arg and disregards the first. </p>

<p>Does anyone have a cleaner way of doing this? I'm assuming I can search for multiple patterns via REGEX, any REGEX masters out there care to help?</p>

<p>Cheers.</p>
