我如何找到段落中的电子邮件ID或任何电话号码 [英] how can i find there is email id or any phone number in paragraph

查看:117
本文介绍了我如何找到段落中的电子邮件ID或任何电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


有人可以告诉我如何在段落中找到电子邮件ID或任何电话号码吗?

例如

在文本框中,我写了一些文本,我只想知道该文本中是否有任何电子邮件ID或电话号码


谢谢

Hello Everyone


Can anybody tell me how can i find there is email id or any phone number in paragraph?

for example

in textbox i write some text and i just want to know there is any email id or phone number in that text or not


Thank you

推荐答案

正则表达式可以解决您的问题
http://msdn.microsoft.com/en-us/library/system. text.regularexpressions.regex.aspx [ ^ ]
Regular Expression can solve your problem
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]


取值并验证IsNumeric()函数,并检查是否为真,您会发现它是否还有其他电子邮件号码.
Take the value and verify to IsNumeric() function, and check for true and false, u will find it whether it number else email.



您可以使用正则表达式来解析段落的内容,可以使用下面的代码,
Hi,
You can use regular expression to parse the content of paragraph, you can use the code below,
MatchCollection matchEmails=Regex.Matches(STRING_TO_MATCH, @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.Compiled | RegexOptions.Multiline);
MatchCollection matchPhones = Regex.Matches(STRING_TO_MATCH, @"[2-9]\d{2}-\d{3}-\d{4}", RegexOptions.Compiled | RegexOptions.Multiline);


您将在matchEmails中找到匹配的电子邮件,在matchPhones 中找到匹配的电话号码.


You will find matched emails in matchEmails and matched phone number in matchPhones .


这篇关于我如何找到段落中的电子邮件ID或任何电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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