Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001092

Re: [PHP] Problem: ereg doesn't work ok (?). From: * R&zE: (renze <email protected>)
Date: 09/18/01

<Original message>
From: Lic. Rodolfo Gonzalez Gonzalez <rodolfo <email protected>>
Date: Mon, Sep 17, 2001 at 05:13:04PM -0500
Message-ID: <Pine.LNX.4.33.0109171710090.4190-100000 <email protected>>
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 <email protected> -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>