Regular Expressions 101

Quiz_13_Match_Alternating_0s_And_1s_In_Any_Order

Open Workspace
  • PCRE2 (PHP)
  • Substitution
2

Regular Expression

/
\b(?!\d(\d)\1)[01]+\b
/
gim

Description

I'm trying to match bit sequences which are alternating between 1 and 0 and never have more than one 1 or 0 in a row. They can be single digits.

Try matching this: 0101010, 1010101010 or 1

Submitted by Anonymous