[英]Validate a specific country Carrier operator phone number regex c#
I need to validate a phone number for a specific carrier operator using RegEx in C#, eg 94773650101 94 is the country code 77 is the carrier operator it can also be 76 how do I validate this using RegEx in C#. 我需要使用C#中的RegEx验证特定运营商的电话号码,例如94773650101 94是国家/地区代码77是运营商,也可以是76如何在C#中使用RegEx验证此电话。 I need a format for it.
我需要一种格式。
I've tried 我试过了
var match = Regex.Match(mobileNo, @"\d947(\d7|6)\d{7}/");
All is very simple, try this: ^947[76]\\d{7}$
一切都很简单,请尝试以下操作:
^947[76]\\d{7}$
There is an errors in your regexp: \\d 947( \\d 7|6)\\d{7} / 您的正则表达式中有一个错误: \\ d 947( \\ d 7 | 6)\\ d {7} /
I've mark it bold. 我将其标记为粗体。 You don't need to use
\\d
before 947
or 7|6
, \\d
is any digit. 您不需要在
947
或7|6
之前使用\\d
, \\d
是任何数字。 And what for /
at the end? 和什么
/
在结束了吗?
UPD for leading zeroes: UPD前导零:
^(00)?947[76]\\d{7}$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.