You needn't use split(). A regex is sufficient:
my $str = "foo|{baz|qux}|fax"; my @parts = $str =~ /( \{.+?\} # e.g., {baz|qux} | [^|]+ # e.g., foo ) (?:\||$) # |, or end of string /xg; $" = "\n"; print "@parts"; __END__ foo {baz|qux} fax
In reply to Re: Split unless contained by
by dws
in thread Split unless contained by
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |