in reply to Re: Re: Regex dynamics
in thread Regex dynamics

I did not read carefull enough. Try this line.
my $q; $q = qr/(?:\[(?:(?>[^\[\]]+)|(??{$q}))+\])/;
Boris

Replies are listed 'Best First'.
Re^4: Regex dynamics
by Hena (Friar) on Feb 11, 2004 at 10:18 UTC
    Ah, my bad on last post :P. Meant that the [] are captured (not matched as written there).
    t[tag]: happens $1 == t $2 == [tag] instead of $1 == t $2 == tag
    My bad on explanations. I should be more careful on how to write (or think beforehand instead of just writing... :)).
      ok, but what should happen on cases like this?
      P[[bb]] x[xx[x]] Z[[z]y] X[a[s]x] V[a[b[c[d]f]g]h]
      Boris
        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 :).