P[[bb]]
$1: P
$2: [bb]
x[xx[x]]
$1: x
$2 xx[x]
Z[[z]y]
$1: Z
$2: [z]y
X[a[s]x]
$1: X
$2: a[s]x
V[a[b[c[d]f]g]h]
$1: V
$2: a[b[c[d]f]g]h
Also to not forget V[a]C[b] (multiple tags in line) should be allowed as well. So the current one is quite nice (which does pretty much everything). But removing outermost pair of [] is pretty trivial (if done outside the already used regex).
my ($key,$value)=($1,$2);
$value=~s/^\[|\]$//g;
So as i said i can live with it :). |