Regex matching only '0' or '1' char (not repeated) : <p>I want to have a regex that matches only the string <code>0</code> or <code>1</code>.</p>

<p>I don't want to get a match if the string is <code>00</code>, <code>11</code> or <code>0101001</code> or any other combination. Just match if <code>0</code> or <code>1</code>.</p>

<p>This is the closest I get:</p>

<p><code>(0|1){1}$</code> but as you can see here this matches the last 1 or zero in a string.</p>
