I am self-studying regular expressions and found an interesting practice problem online that involves writing a regular expression to recognize all binary numbers divisible by 3 (and only such numbers). To be honest, the problem asked to construct a DFA for such a scenario, but I figured that it should be equivalently possible using regular expressions.
I know that there's a little rule in place to figure out if a binary number is divisible by 3: take the number of ones in even places in the digit and subtract by the number of ones in odd places in the digit - if this equals zero, the number is divisible by 3 (example: 110 - 1 in the even 2 slot and a 1 in the odd 1 slot). However, I'm having some trouble adapting this to a regular expression.
The closest I've come is realizing that the number can be 0, so that would be the first state. I also saw that all binary numbers divisible by 3 begin with 1, so that would be the second state, but I'm stuck from there. Could someone help out?