Hello, I am trying to write a code to obtain certain tables (both in text and html formats) from text documents. I am having trouble obtaining the data between the 'Table' tags. Here are key pieces of my current code:

my $startstring='(<table)'; my $keywords='((Beneficially\s*Owned)|(Beneficial\s*Owners)|(Security\ +s*Ownership)|(more\s*than\s*5\spercent)|(more\s*than\s*5\%)|(more\s*t +han\s*five\s*percent)|(All\s*Directors\s*and\s*Executive\s*Officers)| +(Preferred\s*Stock))'; my $endstring='(\/table>)'; { # this step removes the default end of line character (\n) # so the the entire file can be read in at once. local $/; open (SLURP, "$direct$slash"."$file") or die "can't open $file: $!"; #read the contents into data $data = <SLURP>; } @finds=$data=~m/$keywords\s*.{0,1500}\s*($startstring.*?$endstring)/gi +sm;

The issue is is that I am obtaining matches of $keywords, etc. I want to obtain just what is inside the parentheses of my regex above. Any help would be greatly, greatly appreciated. Thanks so much.


In reply to Matching Multiple Multiple-Line Regex by kbone

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.