Regular Expressions 101

Community Patterns

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 - 2 months ago (Last modified 2 months ago)