multiline perl search and replace (one-liner)

Posted by yaya3 on Stack Overflow See other posts from Stack Overflow or by yaya3
Published on 2010-05-26T11:24:04Z Indexed on 2010/05/26 12:51 UTC
Read the original article Hit count: 368

Filed under:
|
|
|

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 white space and/or new lines, 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>         
</div>

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl