title: Swapping a character for another in Regex/Javascript
body: <p>I'm looking to do something like:  </p>
  
  <pre><code>var a = "This is an A B pattern: ABABA";  
  a.replace("A", "B");  
  a.replace("B", "A");  
  </code></pre>
  
  <p>and have it return:<br>
      => "This is an B A pattern: BABAB"<br>
  instead of:<br>
      => "This is an A A pattern: AAAAA"  </p>
  
  <p>My first thought is to do something like:  </p>
  
  <pre><code>a.replace("A", "improbablePattern");  
  a.replace("B", "A");  
  a.replace("improbablePattern", "B");  
  </code></pre>
  
  <p>How should I really be doing it?</p>