fork download
  1. my $str = "abc {{xyz} abc} {xyz} {abc} {{xyz}} abc";
  2.  
  3. while ($str =~ /(\{(?:(?1)|[^{}]*+)++\})|[^{}\s]++/g) {
  4. print "$&\n"
  5. }
Success #stdin #stdout 0s 3608KB
stdin
Standard input is empty
stdout
abc
{{xyz} abc}
{xyz}
{abc}
{{xyz}}
abc