Re: ereg Confusion

From: Date: Mon, 06 Nov 2000 19:38:12 +0000
Subject: Re: ereg Confusion
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23967@lists.php.net to get a copy of this message
If the whole string is ME-xxxxx and nothing else then $value = "ME-12345"; ereg("ME-([0-9]{5,5})$", $value) should do it (note the dollar to denote the end of the string.) Mark. ----- Original Message ----- From: "Jamie Alessio" <alessio@mvfx.com> To: <php-general@lists.php.net> Sent: Monday, November 06, 2000 7:26 PM Subject: [PHP] ereg Confusion > I need to validate user input for tags that are in the format of "ME-xxxxx" where 'x' is > numeric. The input needs to start with "ME-" and then have 5 numbers. I created the > following regular expression but I am not getting the results I would expect. It evaluates > false if I change the "ME-" or put any non-numeric value after "ME-" but it still > evaluates true if there are more than five numbers after "ME-". > > -- Evaluates TRUE > $value = "ME-12345"; > ereg("ME-([0-9]{5,5})", $value) > > -- Evaluates FALSE > $value = "ME-1X345"; > ereg("ME-([0-9]{5,5})", $value) > > -- Evaluates True > $value = "ME-123456789012345678"; > ereg("ME-([0-9]{5,5})", $value) > > Am I missing something? This seems like it should produce the desired results. > > Config: > PHP 4.0.2 > FreeBSD 4.1 > Apache 1.3.12 > > Thanks. > > - Jamie > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#23967) next »