用于验证字符串的正则表达式,后跟US Phone nuber [英] Regular expression to validate string followed by US Phone nuber

查看:83
本文介绍了用于验证字符串的正则表达式,后跟US Phone nuber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


任何人都可以给我一个字符串后跟日期的正则表达式.我可以使用
C#代码页中的正则表达式.

例如电话号码:123-456-7890",电话号码:123.456.7890",电话号码:(123)456 7890"等.


谢谢

Hi
Can anybody give me the regular expression for a string followed by a date.I can use
this regular expression in c# code page.

for example "Phone Number : 123-456-7890","Phone Number : 123.456.7890","Phone Number : (123) 456 7890" etc.


Thanks

推荐答案

听起来像是普通模式.有很多可供使用的示例,例如:
使用通用模式 [
Sounds like common pattern. There a lot of examples which ready for use, for example here:
Using Common Patterns[^]


嗯,对于您在下一个模式上方给出的示例申请.


^(电话号码\ s:\ s)(((\ d {3}-){2} \ d {4})|((((\ d {3} \ d){2} \ d { 4})))((\(\ d {3} \)\ s {1} \ d {3} \ s {1} \ d {4}))
Well, for the examples you give above the next pattern would apply.


^(Phone Number\s:\s)(((\d{3}-){2}\d{4})|(((\d{3}\d){2}\d{4}))|(\(\d{3}\)\s{1}\d{3}\s{1}\d{4}))




我的表情更加紧凑,但这使我有机会匹配三个示例的混合,而且我不知道那是否是你想要的.

它可能不会涵盖您要支持的每种格式,但是它为您提供了一个很好的起点.

希望对您有所帮助!


I had a more compact expression but it gave me the opportunity to match mixes of the three examples and I have no idea if that is what you want.

It will probably not cover every format you want to support, but it gives you a good starting point.

Hope it helps!


这篇关于用于验证字符串的正则表达式,后跟US Phone nuber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆