fork(2) download
  1. #!/usr/bin/perl
  2. # your code goes here
  3.  
  4. $txt = "1,2,3,{4,5,6,7,8},9,10,100";
  5. $txt =~ s/(\{\s*|(?<!^)\G)(\d+),(?=[,0-9]*\})/$1$2|/g;
  6. print $txt;
Success #stdin #stdout 0s 6000KB
stdin
Standard input is empty
stdout
1,2,3,{4|5|6|7|8},9,10,100