ereg code needed..

Ok, here is what I need to do:

The game I play generates a unique ID for each player. This ID is 32 characters long, and contains only numbers 0-9 and letters a-f (I beleive it is an MD5 hash). A common error when entering this ID into forms is they miss letters out or use o's (O) or l's (L) instead of zeros and ones.

The missing letters is easy (strlen), but what about each letter/number? I realise I could loop through each letter/number and check it's ASCII code is within the two ranges, but is there some snazzy ereg code I can use? Or would the loop be better?

Who is Participating?
keteracelConnect With a Mentor Commented:
oops, this one works!


$str = "1234567890abcefdac127dce4638ae22";

if (preg_match("/^[0-9a-f]{32}$/", $str)) {
  echo "correct";
else {
  echo "incorrect";

if (preg_match("/$[0-9a-f]{32}^/", $str)) {
  echo "correct";
rjdownAuthor Commented:
Great stuff, thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.