Community Patterns

Community Library Entry

2

Regular Expression
Created·2024-10-08 14:03
Flavor·PCRE2 (PHP)

/
\b(?!\d(\d)\1)[01]+\b
/
gim
Open regex in editor

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