Re: Simple regexp

From: Date: Fri, 30 Aug 2002 05:25:26 +0000
Subject: Re: Simple regexp
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114601@lists.php.net to get a copy of this message
Hi, you would be better off with preg_match, as its a little quicker apparently. try: preg_match("/^[:0-9a-f]*$/i",$string) or change the * to a + to ensure $string is not null the main problems you had: - not ensuring that only those characters are found by using ^ and $ - not allowing multiple character by using * or + or alternative - having A-Za-Z instead of A-Fa-F I hope this helps Todd. Note: I used /i to be non case dependant, maybe dropping it and having A-F as well would be quicker.. not too sure. ----- Original Message ----- From: "Adam Alkins" <adam@rasadam.com> To: "PHP List" <php-general@lists.php.net> Sent: Friday, August 30, 2002 3:19 PM Subject: [PHP] Simple regexp Hi, I'm trying to do a simple regexp to validate if a whole string only contains the numbers 0 to 9, Letters a - f and A - F and the character : Why isn't ereg("[a-zA-Z0-9:]",$string) working? Guidance appreciated. -------------- Adam Alkins http://www.rasadam.com --------------

« previous php.general (#114601) next »