正则表达式用于验证 [英] Regular expression for validation
问题描述
我需要验证新泽西纳税人身份证号码
此长度控制12位数。
验证方案:
此控件仅包含12位数。
全部12位数字不相同。
Ex:111111111111
..
999999999999
它不应该是序列顺序
如123456789012
它不应包含最后三位数为零
如543044885000
我需要一个正则表达式用于所有上述场景。
先谢谢。
-
最好的问候
Ranganth potluri
Hi,
I need to validate New jersey Taxpayer Identification Number
The length of this control 12 digits.
The validation scenarios:
This control contains only 12 digits.
all 12 digits are not same.
Ex: 111111111111
..
999999999999
it should not be sequence order
like 123456789012
It should not contain last three digits are zeroes
like 543044885000
I need one regular expression for all the above scenarios.
Thanks' in advance.
--
Best Regards
Ranganth potluri
推荐答案
我不会使用正则表达式:你可以指定正则表达式来匹配 12
数字然后你可以轻松检查al l代码中的其他条件。
I won't use regular expression for that: you might specify the regular expression for matching just the 12
digits then you may easily check all the other conditions in code.
根据上面CPallini
的建议,您应该只检查12位数字。见以下链接
JavaScript:电话数字验证 [ ^ ]
对于其他情况,您可以使用以下内容
Excatly as per the suggestion fromCPallini
above,you should check for just 12 digits.For reference see below link
JavaScript :Phone Number validation[^]
For other scenarios,you can use something like below
string temp="eranganath";
现在temp [0]会给你'e'。就像这样你可以比较你的字符串编码。
这只是向您展示如何继续前进的示例。
问候.. :笑:
now temp[0] would give you 'e'.Just like this you can compare your strings in coding.
This is just example to show you how to go ahead.
Regards.. :laugh:
static void Main(string[] args)
{
string[] ids = new string[]
{
"111111111111",
"999999999999",
"123456789012",
"456789012345",
"543044885000",
"124689124000",
"317238921101",
"772190300023"
};
string repeat = @"(?!(\d)\1+
这篇关于正则表达式用于验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!