Just when you thought it was safe - I pop up again!
I have been putting some of the things I have learnt into practice and have started a rewrite on the project I was working on, but came across this small problem,
// VRM Check(s)
$regexs = [
0 => "/^([a-z]{2}[0-9]{2})\s?([a-z]{3})$/", // AB12 ABC
1 => "/^([a-z]{1}[0-9]{1,3})\s?([a-z]{3})$/", // A1 ABC, A12 ABC, A123 ABC
2 => "/^([a-z]{3})\s?([0-9]{1,3}[a-z]{1})$/", // ABC 1A, ABC 21A, ABC 321
3 => "/^([a-z]{2})\s?([0-9]{4})$/", // AB 1234
4 => "/^([0-9]{4})\s?([a-z]{2})$/", // 1234 AB
//5 => "/^([a-z]{3})\s?([0-9]{3})$/", // ABC 123
6 => "/^([a-z]{3})\s?([0-9]{4})$/", // ABC 1234
7 => "/^([a-z]{1,3})\s?([0-9]{1,3})$/", // 1 A, 1 AB, 1 ABC, 12 A, 12 A, etc
8 => "/^([0-9]{1,3})\s?([a-z]{1,3})$/", // A 1, AB 1, ABC 1, A 12, AB 12, etc
];
foreach( $regexs as $regex ) {
if( preg_match( $regex, $_POST['vrm'], $matches ) ) {
break;
}
}
How do I make this leaner and cleaner?