Regular Expressions 101

Enclose <div> tag with <p> tag when inside <p> tag

Open Workspace
  • PCRE (Legacy)
  • Substitution
0

Regular Expression

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

Description

Change the tags only when they are within a tag.

Submitted by LukStorms