Binary String Regular Expression

A regular expression to match and validate a Binary String (a sequence of bytes).

/^\d{3}\s?\d{3}$/

Matches

  • 100110
  • 0101100
  • 01011001110

Non-matches:

  • 123456
  • 01011002
  • abcdefg