Re: Regular Expression help!
- From: "Suk" <sukesh@xxxxxxxxxx>
- Date: 31 Jan 2007 08:00:55 -0800
On 31 Jan, 15:07, Josef Moellers <josef.moell...@xxxxxxxxxxxxxxxxxxx>
wrote:
Suk wrote:
Look at the excerpt from a CSV file below
"C29560","Some text ","07/12/2006 11:00:00","07/12/2006
16:00:00","07/12/2006 16:00:00","07/12/2006 11:00:00","NODE21A3"
I am trying to write a snippet of perl that will swap the date and
year bits in all of the date fields, so that 07/12/2006 becomes
2006/12/07. So the line should read:
"C29560","Some text ","2006/12/07 11:00:00","2006/12/07
16:00:00","2006/12/07 16:00:00","2006/12/07 11:00:00","NODE21A3"
Any help would be appreciated !
What have you tried so far?
Where does your code not meet your expectations?
Using Text::CSV_XS, split and join this is a trivial exercise.
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
I have tried
open CSVFILE, "data.csv" or die "failed to open changes $!";
while (<CHANGES>) {
print "$`$3/$2/$1$'" if (/(\d{2})\/(\d{2})\/(\d{4})/);
}
Sort of works but doesnt get all of them
.
- Follow-Ups:
- Re: Regular Expression help!
- From: Suk
- Re: Regular Expression help!
- References:
- Regular Expression help!
- From: Suk
- Re: Regular Expression help!
- From: Josef Moellers
- Regular Expression help!
- Prev by Date: Re: sort an array unique.
- Next by Date: Re: Regular Expression help!
- Previous by thread: Re: Regular Expression help!
- Next by thread: Re: Regular Expression help!
- Index(es):
Relevant Pages
|
|