Hi there!! I am having a little big problem here trying to match everything that is inside of the TABLE tag and substitute all it's content with nothing, the code that I am using seems to match only if the string had no new line, as soon as a new line is found the regular expression doesn't match any more, any help on how I could repair this error?
Here is the part of the text file I am trying to work with:
<tr> <td colspan=3> <table border="0" cellspacing="0" cellpadding +="2" bgcolor="#ffffff"> <tr> <td width="100%" align="left"><strong> <a href='http://www.webtesting.com/cgi-b +in/test.cgi> <!--&user=default --><!--a href='test.pl +?&user=default&theme=default' --> <font size="2"><small>Click here to mak +e this your default!</small></font></a> </strong></td> </tr> </table> <form> <input type="button" name="Submit" onClick +="top.opener.location.reload(1); top.close()" value="GO!" style="font +:9pt arial; background:silver"></p> </form> </td> </tr> </table> </body> </html>
So I am trying to find everything that is inside of the table tags ans get rid of it.
Here is the perl code
open(FILE, "$text_file") || print "Can't open output file1: $text_file +\n"; while(<FILE>) { if ($_=~/<table>(.*)<\/table>/sg) {$_=~s/<table>(.*)<\/table>//s +g;} $save=$save.$_; } my $file2 = "search_test2.txt"; open(DATA_OUT, ">$file2") || print "Can't open output file1: $file2\n +"; print DATA_OUT $save; close FILE; print $save;
Thanks!!!

In reply to Regular Expression by Anonymous Monk

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.