Regular Expressions 101

Community Patterns

1...45678...901

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?:<p>|\G)[^<>]*?\K(<div>.*?<\/div>)|<\/p>\K(?R)
/
g

Description

Change the <div> tags only when they are within a <p> tag.

Submitted by LukStorms - 8 years ago