in reply to Can I use backreferences as quantifiers in a regex?

/ \# (\d) ( (??{ "\\d{$^N}" }) ) ( (??{ "(?s:.{$^N})" }) ) /x

Your have a second bug. You can't match chr(0x0A) in the binary data. I fixed this by adding the "s" modifier.

Replies are listed 'Best First'.
Re^2: Can I use backreferences as quantifiers in a regex?
by johnbo (Initiate) on Mar 30, 2009 at 06:07 UTC
    This works beautifully.

    I tried this without the ^N for a while, but couldn't get the backreferences to work. Thanks for the new knowledge about the 'postponed eval' and the ^N.

    I had seen the postponed eval previously, but had stayed away from trying it due to the comments about 'highly experimental'.

    Thanks for everyone's help!

    johnbo

      $1 could be used for the first $^N, and $2 the second, but $^N is more meaningful.

      They're not that experimental, and they're require to do what you want to do in a match op.