How can I remove HTML span tags with a Perl one liner?
- by yaya3
I want to perform the following vim substitution as a one-liner in the terminal with Perl. I would prefer to allow for any occurences of whitespace or newlines, rather than explicitly catering for them as I am below.
%s/blockDontForget">\n*\s*<p><span><a\(.*\)<\/span>/blockDontForget"><p><a\1/g
I've tried this:
perl -pi -e 's/blockDontForget"><p><span><a(.*)<\/span>/blockDontForget"><p><a$1/msg'
I presume I am misinterpreting the flags. Where am I going wrong? Thanks.
EDIT:
The above example is to strip the spans out of the following html:
<div class="block blockDontForget">
<p><span><a href="../../../foo/bar/x/x.html">Lorem Ipsum</a></span></p>
EDIT:
It's just the <span>'s and </span>'s that are inbetween <p> and <a> from the "blockDontForget" class
</div> that I want to remove (there are lots or these blockDontForget divs with spans inside anchors that I want to keep).