Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 18-Jun-11 1:57am
v2

 
Share this answer
 
v2
Comments
narendrarathod 18-Jun-11 10:17am    
thank you i got solution
Take the value and verify to IsNumeric() function, and check for true and false, u will find it whether it number else email.
 
Share this answer
 
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);

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900