Last active
September 9, 2024 12:50
-
-
Save wesamly/37f3f64c2cd3fb2f9056cd27ae24796f to your computer and use it in GitHub Desktop.
Libyan National Number Regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Total Length: 12 digits | |
* [1][2002][0012345] | |
* | | | | |
* | | -> Random: 7 digits | |
* | -> Birth Year: 4 digits | |
* -> Gender 1 male / 2 female: 1 digit | |
*/ | |
$value = '120020012345'; | |
//from 1900 - 2099 | |
$pattern = '/^(1|2)(19|20)[0-9]{2}[0-9]{7}$/'; | |
if (preg_match($pattern, $value)) { | |
echo 'Valid NID Number'; | |
} else { | |
echo 'Invalid NID Number'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment