Looking for some help on how to validate a string in PHP.
My string contains:
- 4 NUMBER
- 1 LETTER
- 5 NUMBER
all in one entry, so like 1234A12345.
I need to make sure/validate this before inserting in the DB.
Can one of the wizard help me out there?
This is a pretty simple regex:
/^\d{4}[a-zA-Z]\d{5}$/
code $regex = '/\d{4}[a-zA-Z]\d{5}/'; if (!preg_match($regex, $myref)) { die('Please ensure the reference you enter is in the correct format.'); } codelike this (actual text looks like `like this`).