简体   繁体   English

用于验证约旦国家号码的正则表达式

[英]Regular expression to validate Jordanian National Number

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; 身份是通过将身份所有者信息串联起来组成的。例如,以下身份98610589069由以下组成:

  • 986 = Year of birth ( 1986 ) 986 =出生年月( 1986
  • 1 = Gender. 1 =性别。 ( 1 means male, 2 means female) 1男性, 2女性)
  • 05 = refer to the city of birth. 05 =指出生城市。
  • 89096 = refer to the incremental number for total born in that year, in that city. 89096 =指该年该城市出生89096总数的增量数字。

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 . 这是regex101regexr上的工作演示。

So, the main issues I see in your Regex are 因此,我在Regex中看到的主要问题是
(1) You are not matching city code (1)您的城市代码不匹配
(2) You are taking last part as length = 6 (2)您正在取最后一部分作为长度= 6

试试这个: ^[0-9]{3}[12][0-9]{7}$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM