Help with Regular Expression

A

Ash

Hi
I need help with a regex to substitute all spaces with commas, but not
those spaces that lie within double quotes or square brackets.

Input string (this is one long string)
201.7.42.5 - - [12/Dec/2005:10:34:34 +0000] "GET
/liveupdate-aka.symantec.com/1132200683jtun_ennfull
2.x86 HTTP/1.1" 000 2579078 "-" "Symantec LiveUpdate" "-"

Expected Output
201.7.42.5,-,-,[12/Dec/2005:10:34:34 +0000],"GET
/liveupdate-aka.symantec.com/1132200683jtun_ennfull
2.x86 HTTP/1.1",000,2579078,"-","Symantec LiveUpdate","-"

thanks
Ash
 
P

Paul Lalli

Ash said:
Hi
I need help with a regex to substitute all spaces with commas, but not
those spaces that lie within double quotes or square brackets.

Have you checked the Perl FAQ? Please do so before posting:

perldoc -q inside
How can I split a [character] delimited string except when
inside [character]?

Paul Lalli
 
A

Ash

I'm sorry Paul, I just started on Perl last week and had no idea about
perldoc. Did some search on google to see what it is. As luck would
have it, I got the message

ksh: perldoc: not found

finally I found what you were referring to at perldoc.perl.org

thanks a lot
Ash
 
T

Tad McClellan

Ash said:
I'm sorry Paul,


Sorry for what?

Please quote some context in followups like everybody else does.

I just started on Perl last week and had no idea about
perldoc. Did some search on google to see what it is.


Have you seen the Posting Guidelines that are posted here frequently?

As luck would
have it, I got the message

ksh: perldoc: not found


perldoc is part of a normal install of perl itself.

Either it _is_ somewhere on your system, or you don't have
a normal installation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top