Regular Expressions 101

Community Patterns

Match nth occurence of expression

1

Regular Expression
PCRE (PHP <7.3)

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

Description

Change the number in curly braces (3 in this example) to match for the nth occurence of the expression in the two inner parenthesis

Submitted by Alex Hall - 9 years ago