title: Regex for binary multiple of 3
body: <p>I would like to know how can I construct a regex to know if a number in base 2 (binary) is multiple of 3. I had read in this thread <a href="https://stackoverflow.com/questions/844867/check-if-a-number-is-divisible-by-3">Check if a number is divisible by 3</a> but they dont do it with a regex, and the graph someone drew is wrong(because it doesn't accept even numbers). I have tried with: ((1+)(0*)(1+))<em>(0</em>) but it doesn't works for some values. Hope you can help me.</p>
  
  <p>UPDATE:
  Ok, thanks all for your help, now I know how to draw the NFA, here I left the graph and the regular expresion:</p>
  
  <p>In the graph, the states are the number in base 10 mod 3.</p>
  
  <p>For example: to go to state 1 you have to have 1, then you can add 1 or 0, if you add 1, you would have 11(3 in base 10), and this number mod 3 is 0 then you draw the arc to the state 0.</p>
  
  <p><img src="https://i.stack.imgur.com/5wqTS.png" alt="Whiteboard version"></p>
  
  <p><code>((0*)((11)*)((1((00) *)1) *)(101 *(0|((00) *1 *) *0)1) *(1(000)+1*01)*) *</code></p>
  
  <p>And the other regex works, but this is shorter.</p>
  
  <p>Thanks a lot :)</p>