I'm try to write a regular expression that validate Jordanian national number/ Identity.
The Identity is made up by concatenating from the Identity owner information For example for the following identity 98610589069
is made up of;
986
= Year of birth ( 1986
) 1
= Gender. ( 1
means male, 2
means female) 05
= refer to the city of birth. 89096
= refer to the incremental number for total born in that year, in that city. Can anyone help?
You can try this
^[90][0-9]{2}[12][0-9]{2}[0-9]{5}$
What it'll do is
[90][0-9]{2} - matches 000 to 999 (year 1900 to year 2099, assuming the date range)
[12] - matches 1 or 2 for gender
[0-9]{2} - matches 00 to 99 (assuming city code 00 - 99)
[0-9]{5} - 5 digit sequence number
Here are working demos at regex101 and regexr .
So, the main issues I see in your Regex
are
(1) You are not matching city code
(2) You are taking last part as length = 6
试试这个: ^[0-9]{3}[12][0-9]{7}$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.