Re: split and grouping in regexp





I'm using:
my ( $yyyy, $mm, $dd ) = split /(-|\/)/, $yyyymmdd;
but it doesn't work.


Hello,

try split /\W/,$string pls.

$ perl -le '$str="2006/10/31";my ( $yyyy, $mm, $dd ) = split /\W/, $str;print join " ",$yyyy, $mm, $dd'
2006 10 31

$ perl -le '$str="2006-10-31";my ( $yyyy, $mm, $dd ) = split /\W/, $str;print join " ",$yyyy, $mm, $dd'
2006 10 31

--
Books below translated by me to Chinese.
Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/
.



Relevant Pages

  • Re: File:: Copy
    ... script but when I try to use it latter nothing happens. ... Books below translated by me to Chinese. ... Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/ ...
    (perl.beginners)
  • Re: return 1
    ... This is because it's mostly 'require' d by other scripts then you may need to add '1' at the end. ... Books below translated by me to Chinese. ... Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/ ...
    (perl.beginners)
  • Re: Calling a perl program from a perl script
    ... I need to call that program from a perl script. ... Books below translated by me to Chinese. ... Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/ ...
    (perl.beginners)
  • Re: calling system
    ... cont = 0; ... Books below translated by me to Chinese. ... Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/ ...
    (perl.beginners)
  • Re: Mis-communication between an American individual and a Chinese family
    ... traveling with a Chinese friend. ... You don't give other people's kids books like that - it suggests the ... "We've got the package for some days. ...
    (soc.culture.china)