Hi there,
Imports System.Text.RegularExpressions
Partial Class Signin
Inherits System.Web.UI.Page
Dim source As String = "sdvsdfvsdfhfhggfdgb http://www.mysite.com sdfdf fhgrthwradfedsfg sfcsdf [email protected] adfdf"
Private Function ParseUrl(ByVal d As String) As String
Dim mc As MatchCollection = Regex.Matches(source, "http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase)
For Each m As Match In mc
d = d.Replace(m.Value, String.Format("<a href=""{0}"">{0}</a>", m.Value))
Next
Return d
End Function
Private Function ParseMail(ByVal d As String) As String
Dim mc As MatchCollection = Regex.Matches(source, "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase)
For Each m As Match In mc
d = d.Replace(m.Value, String.Format("<a href=""mailto:{0}"">{0}</a>", m.Value))
Next
Return d
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
source = ParseUrl(source)
source = ParseMail(source)
Response.Write(source)
End Sub
End Class
I hope this helps
Enter your message below
Sign in or Join us (it's free).