in reply to Re: Matching regular expression over multiple lines
in thread Matching regular expression over multiple lines
Just out of curiosity, I went back and tried to solve the original problem with the regex after your tip about the "while" element only reading one line. You were absolutely right, and I should have been writing the following:
(code taken from dsb's answer in Re: Apply regex to entire file, not just individual lines ?). Thanks again!open( FILE, "C:/Users/li/data_collection/posts/165644996453.html" ) || + die "couldn't open\n"; while ( <FILE> ) { $data .= $_; } if ( $data =~ m/(?<=<p>)(.*)(?=<\/p>\s+<footer>)/g ) { print "$1\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Matching regular expression over multiple lines
by haukex (Archbishop) on Oct 16, 2017 at 11:59 UTC | |
by Maire (Scribe) on Oct 16, 2017 at 14:26 UTC |