How to convert a URL inside a string to a hyperlink in VB.NET

1 Answer

0 votes
Imports System
Imports System.Text.RegularExpressions

Class Program
	Public Shared Sub Main()
        Dim str As String = "This is my website check it out https://www.collectivesolver.com"
		
        Dim r As Regex = New Regex("(https?://[^\s]+)")
        str = r.Replace(str, "<a href=""$1"">$1</a>")
		
        Console.WriteLine(str)
    End Sub
End Class


' run:
'
' This is my website check it out <a href="https://www.collectivesolver.com">https://www.collectivesolver.com</a>
' 
 

 



answered May 1 by avibootz
...