I have following regex which gives all urls within a given text

 Dim regex As New Regex("(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)", RegexOptions.IgnoreCase)

now i want to replace all the matches with hyperlinks

     For Each match As Match In mactches
  strtemp &=   strtemp.Replace(match, "<a target='_blank' href='mailto:" & match & "'>" & match & "</a>")

the regex works fine but there is an issue while replacing suppose my text is as follows

"www.google.com is as same as google.com and also http://google.com"

the code will first replace www.google.com with and when second match comes up ie google.com it will again replace the previous one. So what is the way of achieving it

Related posts

Recent Viewed