I’m trying to build a regex to determine if a string contains a byte of binary digits, ex. 10010011.
I believe that [0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1] would work, but I’m sure theres a more efficient way of doing it, and being new to regular expressions, I’m not sure what that is.
If it needs to be exactly 8 (no more/less), use this:
If you don’t want to match something like “abc01010101xyz”, use this:
If you want to match all 8-bit strings anywhere in the input, use this:
Be aware that if you feed the last pattern an input like
1111111100000000, you’re going to get a result set like: