On Sep 9, Mike Singleton said:

>How would I remove all the space and replace them with commas, but where
>there is more than one space in a row, only replace those with one comma? In
>other words make the follwing file comma delimited and strip out everything
>preceding the date?

To turn 1 or more spaces into 1 comma, do:

  s/ +/,/g;

or use tr///:

  tr/ /,/s;

I assume you're only dealing with LITERAL spaces (like " "), and not tabs
or carriage returns or line-feeds.

One problem with

  s/\s/,/g;

or

  s/\s+/,/g;

is that \s matches the newline at the end of each record, so you're
replacing the newlines with commas (ugly and bad).

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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

Reply via email to