Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE2 (PHP >=7.3)

/
\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 - a month ago