Re: Problem: ereg doesn't work ok (?).

From: Date: Tue, 18 Sep 2001 07:54:42 +0000
Subject: Re: Problem: ereg doesn't work ok (?).
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67677@lists.php.net to get a copy of this message
<Original message> From: Lic. Rodolfo Gonzalez Gonzalez <rodolfo@equinoxe.g-networks.net> Date: Mon, Sep 17, 2001 at 05:13:04PM -0500 Message-ID: <Pine.LNX.4.33.0109171710090.4190-100000@equinoxe.g-networks.net> Subject: [PHP] Problem: ereg doesn't work o > Hello, > > I have a problem with ereg: following the example from the documentation > (see the ereg page in the manual), I'm using it to parse a YYYY-MM-DD date > and get DD-MM-YYYY, but with well formed YYYY-MM-DD it doesn't match!. Is > this a bug?. > > Regards, > Rodolfo. > > php-4.0.8-dev (maybe the problem is due to the "dev", but I'd like to > confirm it). </Original message> <Reply> It would help if you send the code you're using, 'cause we can't see what you're doing now. FAFAIK it should just be possible. See the following example: --- PHP Code Example --- <PRE> <?php $myDate = "2001-01-31"; $RE = "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})"; if (ereg ($RE, $myDate, $matches)) { print ("<H1>Matched!</H1>\n\n"); printf ("Year : %4d\nMonth: %02d\nDay : %02d\n", (integer)$matches[1], (integer)$matches[2], (integer)$matches[3]); } else { print ("<H1>Didn't match!</H1>"); } ?> </PRE> --- End of PHP Code Example --- </Reply> -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#67677) next »