mifflin has asked for the wisdom of the Perl Monks concerning the following question:
The problem is I cannot figure out how to make the regex non-greedy. My capturing portion matches the full string, all the way to the last xml file. How to I change the regex to be non-greedy and match up to the first xml file?pos $data = 0; my $len = length $data; while (pos $data < $len) { if ( my ($line) = $data =~ m{ \G ( .+ \. xml ) }gcxms ) { print "$line\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: non-greedy piecewise matching
by ikegami (Patriarch) on Aug 02, 2007 at 17:40 UTC | |
by mifflin (Curate) on Aug 02, 2007 at 19:12 UTC | |
|
Re: non-greedy piecewise matching
by NetWallah (Canon) on Aug 02, 2007 at 16:56 UTC | |
by mifflin (Curate) on Aug 02, 2007 at 17:24 UTC | |
|
Re: non-greedy piecewise matching
by FunkyMonk (Bishop) on Aug 02, 2007 at 16:58 UTC | |
by mifflin (Curate) on Aug 02, 2007 at 17:02 UTC | |
|
Re: non-greedy piecewise matching
by roboticus (Chancellor) on Aug 02, 2007 at 23:04 UTC | |
|
Re: non-greedy piecewise matching
by prasadbabu (Prior) on Aug 02, 2007 at 17:03 UTC |