ADO DOT NET
Centurion
- Joined
- Dec 20, 2006
- Messages
- 160
Hi
Using this REP I wanna extract all emails from a text:
And this is a sample text:
It's my first time I am using Regular Expressions!
so I used and customized this code found in MSDN:
It won't work!
Am I wrong?
Anyone able to help me with this?
Using this REP I wanna extract all emails from a text:
Code:
/[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}/i
Code:
Daves email address dave@mysite.com, Mikes email address mike@example.com,
and Henrys email address henry@sample.org
so I used and customized this code found in MSDN:
Visual Basic:
Dim text As String = "Daves email address [email]dave@mysite.com[/email], Mikes email address [email]mike@example.com[/email], and Henrys email address [email]henry@sample.org[/email]"
Dim pat As String = "/[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}/i"
' Compile the regular expression.
Dim r As Regex = New Regex(pat, RegexOptions.IgnoreCase)
' Match the regular expression pattern against a text string.
Dim m As Match = r.Match(text)
Dim matchcount As Integer = 0
While (m.Success)
matchcount += 1
MsgBox("Match" & (matchcount))
Dim i As Integer
For i = 1 To 2
Dim g As Group = m.Groups(i)
MsgBox("Group" & i & "='" & g.ToString() & "'")
Dim cc As CaptureCollection = g.Captures
Dim j As Integer
For j = 0 To cc.Count - 1
Dim c As Capture = cc(j)
MsgBox("Capture" & j & "='" & c.ToString() _
& "', Position=" & c.Index)
Next j
Next i
m = m.NextMatch()
End While
Am I wrong?
Anyone able to help me with this?