Net-informations.com
SiteMap  | About    

How to validate email address

An Email address has two parts. The part before the @ sign is the local part of the address, and the part after the @ sign is a domain name to which the email message will be sent .

  feedback@net-informations.com

Trying to match these restrictions is a complex task, often resulting in long regular expressions. The .NET Framework provides an extensive set of regular expression tools that enable you to efficiently create, compare, and modify strings as well as rapidly parse large amounts of text and data to search for, remove, and replace text patterns.

  Regex.IsMatch("feedback@net-informations.com", pattern)

Regex.IsMatch Method (String, String) Indicates whether the specified regular expression finds a match in the specified input string. The pattern parameter consists of various regular expression language elements that symbolically describe the string to match pattern . The following vb.net source code shows how to validate an email address with the help of regular expressions.




Imports System.Text.RegularExpressions
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim pattern As String
		pattern = "^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"

		If Regex.IsMatch("feedback@net-informations.com", pattern) Then
			MsgBox("Valid Email address ")
		Else
			MsgBox("Not a valid Email address ")
		End If
	End Sub

End Class






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.