in reply to Re: Split unless contained by
in thread Split unless contained by

if you modify this slightly, and use it in this form it seems to work:
$a = "foo|{baz|qux}|fax"; @b = ($a =~ /( [^|\{]+ | \{ [^}]+ \} ) (?: \| | $ ) /xg);
@b now contains:
$VAR1 = [ 'foo', '{baz|qux}', 'fax' ];
Note that this regexp can't cope with recursive brackets, and can therefore be fooled. Any example of this would be:
$a = "foo|{baz|{qu}x|fax";
which would result in:
$VAR1 = [ 'foo', 'baz', 'qu}x}', 'fax' ];

I'm afraid that I haven't got round to getting the owl book yet, so i'm not really that hot with regexps yet. In fact, i'm coming back to perl now from a years absence. If someone could show how to modify the regexp to cope with things like this, I would be grateful.

Yoda