split and grouping in regexp
- From: dkasak@xxxxxxxxxxxxxxxxxxxx (Daniel Kasak)
- Date: Tue, 31 Oct 2006 12:22:03 +1100
I'm trying to split a date where the values can be separated by a dash '-' or a slash '/', eg:
2006-10-31 or 2006/10/31
I'm using:
my ( $yyyy, $mm, $dd ) = split /(-|\/)/, $yyyymmdd;
but it doesn't work.
If I just do:
my ( $yyyy, $mm, $dd ) = split /-/, $yyyymmdd;
it works for dates separated by dashes, and if I do:
my ( $yyyy, $mm, $dd ) = split /\//, $yyyymmdd;
it works for dates separted by slashes.
Why can't I do both at the same time?
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak@xxxxxxxxxxxxxxxxxxxx
website: http://www.nusconsulting.com.au
.
- Follow-Ups:
- Re: split and grouping in regexp
- From: Dr.Ruud
- Re: split and grouping in regexp
- From: Arnaldo Guzman
- Re: split and grouping in regexp
- From: John W. Krahn
- RE: split and grouping in regexp
- From: Hou Bou
- Re: [SPAM DETECT] split and grouping in regexp
- From: Xavier Mas
- Re: split and grouping in regexp
- Prev by Date: Re: what's wrong with this code?
- Next by Date: Re: [SPAM DETECT] split and grouping in regexp
- Previous by thread: loop over a string to do search/replacement using regexp?
- Next by thread: Re: [SPAM DETECT] split and grouping in regexp
- Index(es):
Relevant Pages
|