[英]How to validate a specific format phone number?
My numbers looks like (###) ###-#### 我的电话号码看起来像(###)###-####
There is a space between the ) and the next digit or my number can look like (###) ###-#### ext #### )和下一个数字之间有一个空格,否则我的电话号码可能看起来像(###)###-####分机####
space after the ext and the ) ext和)后的空格
Can someone tell me what regex needs to be performed to verify if either one is valid. 有人可以告诉我需要执行什么正则表达式来验证其中之一是否有效。 Please note that the extension needs to be 4 digits if one is present.
请注意,如果存在分机号,则必须为4位数字。
I found this RegEx expression on the web 我在网上找到了这个RegEx表达式
Regex.Match(number, @"^(\+[0-9]{9})$").Success
Unfortunately I am not very good at RegEx to understand or modify that 不幸的是,我对RegEx不太了解,无法修改
这个模式怎么样:
@"^\(\d{3}\) \d{3}-\d{4}( ext \d{4}){0,1}$"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.