gpt4 book ai didi

regex - 新加坡 NRIC/FIN 的正则表达式

转载 作者:行者123 更新时间:2023-12-05 08:43:28 25 4
gpt4 key购买 nike

我想检查新加坡的 NRIC/FIN 用户输入数据是否正确。

[A-Z] [0-9]{7} [A-Z] 是正确的正则表达式吗?我是否需要检查第一个字符是 S/F/T/G?如果我需要检查其他情况,请告诉我。

任何想法将不胜感激。谢谢。

最佳答案

看起来这就是您要查找的内容:

^[STFG]\d{7}[A-Z]$

根据 Wikipedia NRIC/FIN article .

The structure of the NRIC number/FIN is #0000000@ where:
# - This is a letter that can be S, T, F or G depending on the status of the holder.
0000000 - This is a 7 digit serial number assigned to the document holder
@ - This is the checksum letter calculated based on # and 0000000.

也许,您想让它不区分大小写 ((?i)^[STFG]\d{7}[A-Z]$)。

此外,如果您想进一步验证该代码,检查它是外国人还是新加坡公民的身份证,您需要一个不同的正则表达式。

关于regex - 新加坡 NRIC/FIN 的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29743154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com