Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail pattern for Regular Expressions

Status
Not open for further replies.

Stimpo

Programmer
Apr 30, 2001
3
BE
Hi,

I'm trying to do some server-side validation. To validate an e-mail address I'm using the following regular expressions.

re.Pattern = "^\w+\.\w+@\w+\.\w+"
results = re.Test(email)
If results Then
' Nothing
Else
strError = strError & &quot;* Please enter a correct e-mail address.<br>&quot;
End If

There's a problem with e-mailadresses like jvdh@hotmail.com. When I fill that in, I get an error message to enter a correct e-mail address. This is because there's no dot in the first part. An e-mail address like joris.vanderhoeven@kaneka.be is correct.

What changes do I need to do to the pattern to make sure that both jvdh@hotmail.com and joris.vanderhoev... will be accepted ?

Thanx!
 
I have a JS function that validates email addresses and this is the Regular Expression that I use:

var re = new RegExp(&quot;^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$&quot;);
Mise Le Meas,

Mighty :)
 
When I use your RegExp I get:

Microsoft VBScript runtime error '800a139c'

Expected ')' in regular expression

/admin/adduser.asp, line 59
 
Can you post the line containing the regular expression. Mise Le Meas,

Mighty :)
 

re.Pattern = &quot;^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$&quot;

This is the line when I use your expression
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top