I’m trying to make a regex for National Identification Number for my country.
The format is CF or CM + last 2 digits of birth year + 6 digits + Letter + 2 digits + Letter.
An example is: CF95032102EA1H
or CM95032102EA1H
This is my regex using php. When I run it, it returns Ivalid
$nin_regex = '/^(CF|CM)d{2}[0-9]{6}[A-Z]{1}[0-9]{2}[A-Z]{1}$/';
function validate_nin($nin) {
global $nin_regex;
return preg_match($nin_regex, $nin);
}
if (validate_nin('CF95032102EA1H')) {
echo 'Valid NIN';
} else {
echo 'Invalid NIN';
}