I am new to programming PHP and am trying to validate a field in a form.
The field if for a RAL color code and so would look something like : RAL 1001.
so the letters RAL and then 4 numbers.
Can someone help me set them into a regular expression to validate them.
i have tried this with no success:
$string_exp = "/^[RAL][0-9 .-]+$/i";
What can I say but sorry for being a complete NOOB at PHP.
Cheers
Ben
[RAL]will match just one character, either R, A or L, whereas you want to match the string “RAL”. So you probably want something like this,This will match
"RAL1001", but not"RAL1","RAL 1001","RAL12345", etc. If you wanted the space between RAL and the number, then also put that space into the regexp.