Danny Grzenda wrote:
>
> DB4515C,625.25,378,327,382,352,805,163,513.5,699,257.88,,,"4,503","1,801",80 5
>
> Trying to create a regex to substitute comas with pipes, except for the
> commas between the double quotes.
>
> can't get one to work.
You have to parse the data. Here is some code modified from the perlop manpage:
$ perl -e'
$_ = qq[DB4515C,625.25,378,327,382,352,805,163,513.5,699,257.88,,,"4,503","1,801",80
5\n];
print;
LOOP: {
redo LOOP if /\G"[^"]*"/gc; # bypass quoted strings
redo LOOP if s/\G,/|/gc; # change commas to pipes
redo LOOP if /\G[^,]/gc; # ignore other characters
}
print;
'
DB4515C,625.25,378,327,382,352,805,163,513.5,699,257.88,,,"4,503","1,801",80 5
DB4515C|625.25|378|327|382|352|805|163|513.5|699|257.88|||"4,503"|"1,801"|80 5
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]