in reply to Re: greedy subexpression between two nongreedy ones
in thread greedy subexpression between two nongreedy ones
Although this may be perfectly acceptable, $1 will be undefined if it is not present in the string being searched:
c:\@Work\Perl\monks>perl -wMstrict -le "for my $s (',abcdefg,pqrstuv', ',abefg,pqrstuv', @ARGV) { my $t = $s; print qq{'$t'}; $t =~ s/,(?:.*?(cd))?.*?,/=$1=/; print qq{'$t' \n}; } " ',abcdefg,pqrstuv' '=cd=pqrstuv' ',abefg,pqrstuv' Use of uninitialized value $1 in concatenation (.) or string at -e lin +e 1. '==pqrstuv'
Give a man a fish: <%-(-(-(-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: greedy subexpression between two nongreedy ones
by Anonymous Monk on Jun 02, 2015 at 10:10 UTC | |
by raygun (Scribe) on Jun 02, 2015 at 19:26 UTC | |
by Anonymous Monk on Jun 02, 2015 at 20:43 UTC | |
by raygun (Scribe) on Jun 03, 2015 at 01:26 UTC | |
by Anonymous Monk on Jun 02, 2015 at 21:10 UTC |