Regular Expressions 101

Community Patterns

Match nth occurence of pattern

4

Regular Expression
PCRE (PHP <7.3)

/
(?:.*?(Constr1)+){3}.*?((Constr1)+)
/
s

Description

Match nth occurence of the patterns in the inner parenthesis. Put nth that you want to match in the curly braces (here, {3}).

Submitted by Alex Hall - 9 years ago