title: What regex matches strings of consecutive 'a' and 'b'?
body: <p>I need a regex which matches strings of consecutive <code>a</code> and <code>b</code>, e.g.:</p>
  
  <pre><code>ababa
  bab
  </code></pre>
  
  <p>Edge case (smallest):</p>
  
  <pre><code>ab
  ba
  </code></pre>
  
  <p>(No upper limit.)</p>
  
  <p>...and <strong>shouldn't</strong> match:</p>
  
  <pre><code>abba
  bbab
  bbaabb
  </code></pre>
  
  <p>I've tried several regex but this one is kind of tricky. Can you throw me any hints?</p>
  
  <p>My tries:</p>
  
  <ul>
  <li><code>(a|b)+</code></li>
  <li><code>(ab|ba)*(aba|bab)+</code></li>
  </ul>
  
  <p>This one gets really close! <a href="http://www.regexr.com/38lqg" rel="nofollow">http://www.regexr.com/38lqg</a></p>