Hi Everyone-

I am trying to write a one-liner that uses regexp to extract certain text from html files. Basically what I have so far is this:

perl -e 's/.*?((<a\sname\s\ssometag.*?)<br><br><\sbody>)/$1/sgi' -p -i.bak 1.html

Basically, I want the program to search through the html files for a specific tag, cut the tag and all of the text leading up to the <br><br></body> tags this will then replace all of the original text.

But when I run this command it replaces the original file with an exact copy of the original file instead of the text that is supposed to cut. The re matches correctly, but it will not span the multiple lines of text even though I end with a /s. This same exact re works in other programming languages with a 'dotall' to span multiple lines, but I can't seem to get perl to do it the same way. I would really rather use a perl 'one-liner' instead of writing a large script that would do the same thing.

Any idea's on how to get this to work?

Thanks.
SA
:)

In reply to 'one-liner' help by buc99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.