Regular Expressions 101

Community Patterns

1...34567...881

Unary prime numbers

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?!(.{2,})\g1+$).{2,}$
/
gm

Description

Matches all lines whose length is a prime number and only contain the character "1".

Submitted by pablo - 3 months ago (Last modified 3 months ago)