Jan Eden wrote:
Hi,
Hello,
I use the following regex to split a (really simple) file into sections headed by
<h1>.+?</h1>:
while ($content =~ m#<h1>(.+?)</h1>(.+?)(?=<h1>)#gs) {
...
}
This works perfectly, but obviously does not catch the last section, as it is not
followed by <h1>.
How can I catch the last section without
* doing a separate match for it
* loosing the convenience of the g switch to wade through the whole file?
This should work (untested)
while ($content =~ m#<h1>(.+?)</h1>(.+?)(?=<h1>|\z)#gs) {
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>