3
I have a string with several HTML tags. I want to remove only the first tag <p>
and the last tag </p>
of this string. I found solutions that remove all tags but these do not serve.
Example:
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<p> Nullam feugiat, turpis at pulvinar vulputate</p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</p>
You should stay:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<p> Nullam feugiat, turpis at pulvinar vulputate</p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
I don’t think there’s much to do but manipulate the string directly. The tags are right at the beginning/end of the string, such as
<p>alguma coisa</p>
or is it something more mixed<div><div><p>algumacoisa</p></div></div>
?– Vítor Martins
Always at the beginning and at the end
– Amanda Lima
Amanda did not understand well, want to remove only and only
<p>
of the beginning and</p>
end. Or you want to remove the first/last<p>
in full:<p>REMOVER</p><p>NÂO REMOVER</p><p>REMOVER</p>
– Miguel
I edited the question to show how it should look
– Amanda Lima