Regular Expressions 101

Community Library Entry

2

Regular Expression
PCRE2 (PHP >=7.3)

/
(?=(\b\w{4,}\b)(?:.*\b\1\b){2})(?!(\b\w{4,}\b)(?:.*\b\1\b){3})
/
gi

Description

I'd like to know if a text contains words with 4 characters or more which are repeated 3 or more times in the text (anywhere in the text).

If so, set one (and only one) backreference for each word.

Submitted by anonymous - 2 months ago