Public Function GetAllEMailAddresses(ByVal Input As String) As List(Of String)
Dim Results As New List(Of String)
Dim MC As Text.RegularExpressions.MatchCollection = _
System.Text.RegularExpressions.Regex.Matches(Input, _
"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")
For i As Integer = 0 To MC.Count - 1
If Results.Contains(MC(i).Value) = False Then
Results.Add(MC(i).Value)
End If
Next
Return Results
End Function
-
We use regular expression to find an email id in a text or a sting. And it stores in the list box. I hope you can use this to find email ids. Hope u liked this snippet. If you have any doubts on this ask me.
You can also use this on files. But with little modification.
Get Email IDs from text or string (VB.net)
Tuesday, July 15, 2008Posted by Raghunath J at 6:19 PM
Labels: Code Snippets
Subscribe to:
Post Comments (Atom)
1 comments:
Good post.
Post a Comment