kbone has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching Multiple Multiple-Line Regex
by jwkrahn (Abbot) on Feb 20, 2012 at 22:35 UTC | |
by kbone (Novice) on Feb 21, 2012 at 02:25 UTC | |
|
Re: Matching Multiple Multiple-Line Regex
by JavaFan (Canon) on Feb 20, 2012 at 23:08 UTC | |
by kbone (Novice) on Feb 21, 2012 at 02:26 UTC |