Last active
November 22, 2023 08:31
-
-
Save NimzyMaina/c32e6dc0ca9d6b83c6d28e3e25065677 to your computer and use it in GitHub Desktop.
Regex to validate KRA PIN
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 | |
$kra_regex = "/^[A]{1}[0-9]{9}[a-zA-Z]{1}$/"; | |
$kra_pin = "A001234567J"; | |
if(preg_match($kra_regex, $kra_pin)){ | |
echo "Success! Valid KRA PIN"; | |
} | |
else{ | |
echo "Error! Invalid KRA PIN"; | |
} |
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 | |
function isPinValid($pin) | |
{ | |
return preg_match("/^[A]{1}[0-9]{9}[a-zA-Z]{1}$/", $pin); | |
} | |
$is_valid = isPinValid("A001234567J"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment