RE: split and grouping in regexp



my ( $yyyy, $mm, $dd ) = split /(-|\/)/, $yyyymmdd;
my ( $yyyy, $mm, $dd ) = split /-|\//, $yyyymmdd;
with this it works.

-----Original Message-----
From: Daniel Kasak [mailto:dkasak@xxxxxxxxxxxxxxxxxxxx]
Sent: Tuesday, October 31, 2006 10:22 AM
To: beginners@xxxxxxxx
Subject: split and grouping in regexp


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

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>


.



Relevant Pages

  • Re: tcl8.5 new operator in expr
    ... comparisons considerably less verbose - To my mind the only things missing now are "glob" and "regexp" string comparisons. ... Should every Tcl command have an infix equivalent in? ... These examples assume auto-expansion of leading word when resolving commands. ...
    (comp.lang.tcl)
  • Re: Regexp vs string match
    ... that loop in C are superior performers compared with those that loop in ... Also, if your matching task can be done with one, but is ... beyond the reach of one, the regexp answer may perform better. ... commands with more implementation in C are always superior to commands ...
    (comp.lang.tcl)
  • Any dash fans out there?
    ... I'm trying to build some more functionality into dash, ... memory systems or very small Xen domain-0 hosts. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: search and replace code in php or html files
    ... one line than you'll need a more complex script. ... Might I suggest using multi-line mode in your regexp for those cases? ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: RegExp issues....
    ... lowercase letters, numbers, and underscore, leaving only the dash to be ... putting user inputted text in a shell, but this regExp should do the job ...
    (comp.lang.ruby)