Just for the sake of scientific experiment I tested it and it works ... sort of.
As there is an end-of-line in front of the first 'STRING_I_WANT' and no end-of-line characters after it or around the 'ANOTHER STRING_I_WANT', the result looks rather odd, difficult to read and (almost) impossible to use in a meaningful way.
If you want to further use the result, it seems better to put some 'start' and 'stop' markers around the results:
use strict; use warnings; undef $/; chomp(my $whole_file = <DATA>); print "***\n$whole_file\n***\n"; $whole_file =~ s/.*?Title:.*?<\/b>\s?(.*?)<br>/<WANTED>$1<\/WANTED>\n/ +gs ; print "$whole_file"; __DATA__ a whole lot of worthless stuff <b>Title: </b> STRING_I_WANT<br> more worthless meaningless stuff or sometimes <b>Title: </b>ANOTHER STRING_I_WANT<br>
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: Re: Re: Re: Help with getting everything from X until Y
by CountZero
in thread Help with getting everything from X until Y
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |