Regular expressions are great for evaluating string values and ensuring that
what you get from the user input is what you want. The following three methods
are great for checking input for Internet applications.
The first function is for validating an email address. It accepts the email
address as a string input, and returns a boolean value informing the application
if it is a valid email.
Function IsValidEmail(ByVal email As
String) As Boolean
Return System.Text.RegularExpressions.Regex.IsMatch(email, _
"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")
End Function
The second function is for validating an URL. Again, this function accepts
the URL as a string input, and returns a boolean value informing the application
if it is a valid Internet address.
Function IsValidUrl(ByVal url As String) As
Boolean
Return System.Text.RegularExpressions.Regex.IsMatch(url, _
"(http|ftp|https)://([\w-]+\.)+(/[\w- ./?%&=]*)?")
End Function