Thanks everyone for the help. It worked like a charm. Not actually sure how
it works. Never used 
\G b4. My regex books says its not used very much.

Thanks again.

-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 13, 2002 6:38 PM
To: [EMAIL PROTECTED]
Subject: Re: regex help


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]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to