fork download
  1. #!/usr/bin/perl
  2.  
  3. my $s = "(rupert, paul, 23, 8, [{fin, dan, jack},{bill,34,26,49},{84,28}],{34,jack,bon})\n(rupert, paul, 23, 8, [{fin| dan| jack}|{bill|34|26|49}|{84|28}],{34|jack|bon})";
  4. $s =~ s/,(?=(?:\{[^{}]*\}|[^{}])*})|,(?=(?:\[[^\[\]]*\]|[^\[\]])*\])/|/g;
  5. print "$s\n";
Success #stdin #stdout 0s 6044KB
stdin
Standard input is empty
stdout
(rupert, paul, 23, 8, [{fin| dan| jack}|{bill|34|26|49}|{84|28}],{34|jack|bon})
(rupert, paul, 23, 8, [{fin| dan| jack}|{bill|34|26|49}|{84|28}],{34|jack|bon})