I have a white list of HTML end tags (br
, b
, i
, div
):-
String whitelist = "([^br|^b|^i|^div])";
String endTagPattern = "(<[ ]*/[ ]*)" + whitelist + "(>?).*?([^>]+>)";
...
html = html.replaceAll(endTagPattern, "[r]");
Which takes my test String
and removes the end tags of those not in the white list, in this case replaced by [r]
for clarity:-
1. <b>bold</b>, 2. <i>italic</i>, 3. <strong>strong</strong>, 4. <div>div</div>, 5. <script lang='test'>script</script>
1. <b>bold</b>, 2. <i>italic</i>, 3. <strong>strong[r], 4. <div>div</div>, 5. <script lang='test'>script[r]
If I add strong
to this white list
String whitelist = "([^br|^b|^i|^div|^strong])";
Not only does it not match the strong
end tag, it also stops matching that of the end script
tag or any other for that matter.
My question is, why?