Can you help with this PHP ereg statement?

cmaclean

New member
Hello, I'm in a PHP course and am having trouble with one of the questions. I'm supposed to validate a license plate input. The only valid formats are ABC123 or 123ABC or ABC 123 or 123 ABC.

I've got most of the validation done, the only thing is I'm struggling to disallow this type of input: A1B 2C3. It need to be AAA 123 or vice versa.

Here is what I have so far:

if(eregi("^[a-z0-9]{3} *[a-z0-9]{3}$",$license)){
echo "Thank you, this is what you entered: " . $license;
}
else{
echo "Sorry, we could not process that input.";
}

Thanks!
 
Back
Top