in reply to REGEX detailed character replace

Although not in one regex, this works:
use strict; my $string = '|xx-xxx-xxxxx-xxx x/xx|xx-xxxx-xxx-xx-xxxx-xx-xx|'; print "$string\n"; $string =~ s/\|//; # gets rid of the first pipe $string =~ s/\|/,/g; # replaces all other pipes by commas print "$string\n"; my @chunks = split '-', $string; $string = join( '-', @chunks[ 0 .. 3 ] ) . ',' . join( ',', @chunks[ 4 .. $#chunks ] ); print "$string\n";
giving:
|xx-xxx-xxxxx-xxx x/xx|xx-xxxx-xxx-xx-xxxx-xx-xx| xx-xxx-xxxxx-xxx x/xx,xx-xxxx-xxx-xx-xxxx-xx-xx, xx-xxx-xxxxx-xxx x/xx,xx,xxxx,xxx,xx,xxxx,xx,xx,
Please note that it appears you also replace a space by a comma in your example.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James