Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Community Library
How to contribute
x
Enclose <div> tag with <p> tag when inside <p> tag
Open Workspace
PCRE (Legacy)
Substitution
Created 2016-08-08 07:36
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