[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] Jays back referencing substitution code...or the tangled ugliness of nested parens in reg expressions...or 'HEY YA'LL WATCH THIS!!!'
-laugh-
I'm not sure what real code you're accusing me of writing, but to figure
out $1, $2, $3, simply count the left parens from left to right. The
first left paren is $1, the second is $2, etc.
j
-----Original Message-----
From: Trey Bianchini
Sent: Tuesday, May 15, 2007 10:31 AM
To: Sean Baker; Justin Esbenshade; Jay Hannah
Subject: Jays back referencing substitution code...or the tangled
ugliness of nested parens in reg expressions...or 'HEY YA'LL WATCH
THIS!!!'
echo "J,A,J,B,J,C" | perl -ne ' $_=~m/((J(,A,J),(B)),((J),C))/; print
"one:$1\ntwo:$2\nthree:$3\nfour:$4\nfive:$5\nsix:$6\n" ';
#one:J,A,J,B,J,C
#two:J,A,J,B
#three:,A,J
#four:B
#five:J,C
#six:J
It Seems that they are assigned to placeholder variables starting with
the outermost parens and then going left to right, unesting them
completely before moving to the next leftmost pair.....