Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Regular
Expressions
101
Regular
Expressions
101
Upgrade to Pro
Enterprise
Regular Expression
~
(?(DEFINE) (?<tagName> [a-z][a-z\d]*+ (?=[>\s/]) ) (?<tagAttr> (?> [^>"']++ | " [^"]*+ " | ' [^']*+ ' )*+ ) ) < (li|/ul) /?+ (?=[>\s/]) ((?&tagAttr)) > ((?: [^<]++ | < /?+ (?!(?:li|ul)(?=[>\s/])) (?&tagName) (?&tagAttr) > #any tag except <li> and <ul> | < (?! /?+ (?&tagName) ) #not tag )*) (?= < (?:li|/ul) (?=[>\s/]) (?&tagAttr) ) #check for nested <li> and <ul>
~
gsixuX
Test String
New
<ul> <li fhgfhfg ghgfhfghhfgh= ghghg="..." a = 'ghghg'>dfdsfsd <ul> <li>111</li> <li/>2222 <li>mmmmm</li> </ul> <li>dfdsfdsfsdf <b class="..."><br/>fgdfgd<i></b><!-- dfdf--><li> <li> <li>dsfsdfsdfdsf </ul>
Substitution
Processing...
<$3$4>$5</LI>\r