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