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" <[EMAIL PROTECTED]>
To: "PHP List" <[EMAIL PROTECTED]>
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
--------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php