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#. 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}$
There is an errors in your regexp: \\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. And what for /
at the end?
UPD for leading zeroes:
^(00)?947[76]\\d{7}$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.