I have requirement where I have to Identify 2 point.
- Replace all tag that is having closed tag but exculding few tags Like
<a></a>, <p></p>, <i></i>
. For this I did lots of R&D but not able to find exact solution. My final finding regx :(?!<p|a|i|>)(?<opentag><(?!/)[^>]*[^/]>)
But this is also finding tag that not having closing tag Like <abc>
NOTE: In this I want to replace start and close tag with space.
- If we have Tag that not having closing tag then I want to remove only special symbol not whole tag.
<abc>
should beabc
Example:
Input String:
<br />
<ul id="matchMe" type="square">
<li>stuff...</li>
<li>more stuff</li>
<li>
<div>
<span>still more</span>
<ul>
<li>Another >ul<, oh my!</li>
<li>...</li>
</ul>
</div>
</li>
</ul>
<p>....</p>
<p class="hhh">....</p>
<customTag1> Hello <CustomTag2>
Output String:
stuff...
more stuff
still more
Another >ul<, oh my!
...
<p>....</p>
<p class="hhh">....</p>
customTag1 Hello CustomTag2
In this example I do not want to do anything with p
tag but all other tag that having self closing tag or closing tag should be replace with blank.
customTag1
and CustomTag2
both tags are custom and it's looking like HTML start tag but do not having end tag. For these tag I just want to remove <,>
symbol only.
Few answer helped here but not fully https://stackoverflow.com/a/7564061/4813631 https://stackoverflow.com/a/10267932/4813631
Thanks