Re: Regular Expression help!
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Jan 2007 09:49:31 -0800
On Jan 31, 11:16 am, "Paul Lalli" <mri...@xxxxxxxxx> wrote:
On Jan 31, 11:10 am, "Suk" <suk...@xxxxxxxxxx> wrote:
Sorry I meant -
open CSVFILE, "data.csv" or die "failed to open changes $!";
while (<CSVFILE>) {
print "$`$3/$2/$1$'" if (/(\d{2})\/(\d{2})\/(\d{4})/);
}
Which just alters the first date- I need to alter all of them
So change your pattern-match-within-an-if to s///g, and print the
results.
s/(\d{2})\/(\d{2})\/(\d{4})/$3/$2/$1/g;
print;
Ugh. Gotta escape those last two slashes...
s/(\d{2})\/(\d{2})\/(\d{4})/$3\/$2\/$1/g;
Or, preferably, just stop using / as your delimiter in the s/// :
s!(\d{2})/(\d{2})/(\d{4})!$3/$2/$1!g;
Paul Lalli
.
- References:
- Regular Expression help!
- From: Suk
- Re: Regular Expression help!
- From: Josef Moellers
- Re: Regular Expression help!
- From: Suk
- Re: Regular Expression help!
- From: Suk
- Re: Regular Expression help!
- From: Paul Lalli
- Regular Expression help!
- Prev by Date: Re: How to pass array from java to perl using inline java
- Next by Date: Re: How to pass array from java to perl using inline java
- Previous by thread: Re: Regular Expression help!
- Next by thread: Re: Regular Expression help!
- Index(es):