什么是10位手机号码的正则表达式代码 [英] What is regex code for 10 digit mobile number
问题描述
public static bool hasValidCharforContactNo( string input)
{
Regex r = new Regex( ^ [0-9] {10} $);
if (r.IsMatch(input))
{
return false ;
}
返回 true ;
}
我的尝试:
i我试图使用上面的代码,但它没有正常工作请给我正确的代码
);
if (r.IsMatch(input))
{
return false ;
}
return true ;
}
我的尝试:
i我试图使用上面的代码,但是它运行不正常请给我正确的代码
这是一个测试javascript正则表达式的网站表达式,带有10位数的示例:
RegExr:学习,构建和测试RegEx [ ^ ]
^((\ + | 00(\s | \s?\-\ s ?))31(\s |????\s \-\s)(\(0\)[\-\s])|?0)[1-9] ((\s |?\s \-\s)[0-9]?)((\s |????\s -\s)[0-9])(( \s |??????\s -\s)[0-9])\s [0-9] \s [0-9] \s [0-9] \ s?[0-9] \ s?[0-9]
和11-12位数的另一个数字: RegExr:Learn,Build,&测试RegEx [ ^ ]
这是着名的 Expresso 制造商Jim Hollenhorst写的一篇有趣的文章: 30分钟正则表达式教程 [ ^ ]
以下是荷兰电话号码的工作代码:
//使用System.Text.RegularExpressions;
string searchPattern = @^((\ + | 00(\s | \s?\-\s?)?)31(\s | \ s? \-\s)(\(0\)[\-\s])|????0)[1-9]((\s |?\s \-\\ \\s)[0-9])((\s |?????\s -\s)[0-9])((\s | \s -\s)? ?[0-9])\s?[0-9] \s?[0-9] \s?[0-9] \s?[0-9] \s?[O- 9]
public static bool hasValidCharforContactNo(string input)
{
Regex r = new Regex("^[0-9]{10}$");
if (r.IsMatch(input))
{
return false;
}
return true;
}
What I have tried:
i am trying to use above code but it is not working properly please give me proper code
"); if (r.IsMatch(input)) { return false; } return true; }
What I have tried:
i am trying to use above code but it is not working properly please give me proper code
Here is a site for testing javascript regex expressions, with an example for 10 digits:
RegExr: Learn, Build, & Test RegEx[^]
^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9])((\s|\s?-\s?)?[0-9])((\s|\s?-\s?)?[0-9])\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]
And another one for 11-12 digit numbers: RegExr: Learn, Build, & Test RegEx[^]
Here is an interesting article by the famous Expresso maker Jim Hollenhorst: The 30 Minute Regex Tutorial[^]
And here is the working code for Dutch phone numbers:
// using System.Text.RegularExpressions; string searchPattern = @"^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9])((\s|\s?-\s?)?[0-9])((\s|\s?-\s?)?[0-9])\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]
这篇关于什么是10位手机号码的正则表达式代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!