Elijah has asked for the wisdom of the Perl Monks concerning the following question:
The test code I have is as follows:
This will print out something like this:#!/usr/bin/perl -w use strict; my $string = <<END; start start start go one end start start start go two end END while ($string =~ /(start.+?end)/gis) { print $1,"\n\n"; }
This, of course, is not what I want. I would like it to only print out:start start start go one end start start start go two end
I need somehow to ignore the preceding starts. I have tried using (?:.*) but this only prints out the second group for some reason. Any ideas?start go one end start go two end
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Multiple regex matches in single string
by hipowls (Curate) on Apr 26, 2008 at 04:12 UTC | |
by Elijah (Hermit) on Apr 26, 2008 at 16:23 UTC | |
by johngg (Canon) on Apr 26, 2008 at 22:22 UTC | |
by hipowls (Curate) on Apr 26, 2008 at 23:33 UTC | |
Re: Multiple regex matches in single string
by pc88mxer (Vicar) on Apr 26, 2008 at 04:33 UTC | |
Re: Multiple regex matches in single string
by jethro (Monsignor) on Apr 26, 2008 at 04:11 UTC | |
Re: Multiple regex matches in single string
by hipowls (Curate) on Apr 27, 2008 at 03:37 UTC |