Regular expression for validating format of website Address in

Regular expressions are a good way to validate text fields such as date,names, addresses, phone numbers, and other user information. You can use the System.Text.RegularExpressions.Regex class for validate any input string for any specific format.

The following example will allow you to Input valid website address only:

    Private Sub ValidatewebsiteAddress(ByVal _websiteAddress As String)
        If Not Regex.IsMatch(_websiteAddress, _
       "^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?") Then
            MessageBox.Show("invalid websiteAddress")
            MessageBox.Show("valid websiteAddress")
        End If
    End Sub

More on Regular Expressions