Regular Expressions 101

Community Patterns

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