Fix plate number cleaning #168
This commit is contained in:
parent
0ae1c0cc17
commit
030668e43b
1 changed files with 17 additions and 3 deletions
|
|
@ -133,9 +133,23 @@ class Warranty
|
|||
// remove invalid characters
|
||||
$clean_plate = preg_replace("/[^A-Z0-9]/", '', $clean_plate);
|
||||
|
||||
// check if format is correct
|
||||
// AAA123 or AAA1234
|
||||
$res = preg_match("/^[A-Z]{3}[0-9]{3,4}$/", $clean_plate);
|
||||
// check for 4 to 5 digit diplomatic plate
|
||||
$res = preg_match("/^[0-9]{4,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// ABC-1234 or ABC-123 or ABC-12 format
|
||||
$res = preg_match("/^[A-Z]{3}[0-9]{2,4}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// AB-123 or AB-12345 or AB-1234 format (motorcycles)
|
||||
$res = preg_match("/^[A-Z]{2}[0-9]{3,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// 1234-AB format (motorcycles)
|
||||
$res = preg_match("/^[0-9]{4}[A-Z]{2}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue