1. Junior Member
Join Date
Dec 1969
Posts
6

Hi<BR><BR>I&#039;ve been trying to write a regular expression to perform pretty strict checking on a email address.<BR><BR>The expression that I&#039;ve come up with is<BR><BR>^([a-z0-9](w&#124.w&#124-w)*@[a-z0-9]([a-z0-9]&#124.[a-z0-9]&#124-[a-z0-9]&#124-[a-z0-9])+.(com&#124net&#124edu&#124mil&#124gov&#124org&#1 24[a-z][a-z])\$)<BR><BR>Which I interpret as follows<BR><BR>^( = Beginning of string<BR>[a-z0-9] = one alphanumeric<BR>(w&#124.w&#124-w)* = an alphanumeric (inc _) or a period or a hyphen followed by an alphanumeric (inc _) zero or more times<BR>@ = an @<BR>[a-z0-9] = one alphanumeric<BR>([a-z0-9]&#124.[a-z0-9]&#124-[a-z0-9]&#124-[a-z0-9])+ = an alphanumeric or a period or a hypen followed by an alphanumeric one or more times <BR>. = a period<BR>(com&#124net&#124edu&#124mil&#124gov&#124org&#124[a-z][a-z]) = com, net, edu, mil, gov, org or xx country code<BR>\$) = End of string<BR><BR>But despite trying various bits and building up, I can&#039;t get the whole thing to work together.<BR><BR>Would appreciate any advice.<BR><BR>Thanks<BR><BR>John

2. Junior Member
Join Date
Dec 1969
Posts
4

## RE: Strict email address checking

Sorry I can&#039;t help with your expression but I thought you might find this tool useful when building/analysing regular expressions:<BR><BR>http://www12.brinkster.com/ultrapico/Expresso.htm

3. Member
Join Date
Dec 1969
Posts
51

## RE: Strict email address checking

Well the  &#039;s are redundant if you are using ^ and \$<BR>What failures are you getting? You&#039;re not allowing for uppercase explicitly in the regex.

4. Junior Member
Join Date
Dec 1969
Posts
6

## RE: Strict email address checking

Hi Michael<BR><BR>Thanks for your reply. I&#039;ve moved on a bit and now have:<BR><BR>^[a-z0-9]([a-z0-9]&#124.[a-z0-9]&#124-[a-z0-9]&#124_[a-z0-9])*@[a-z0-9][a-z0-9-_.]*[a-z0-9].(com&#124net&#124edu&#124mil&#124gov&#124org&#124 info&#124[a-z][a-z])\$<BR><BR>This seems to be closer to working, but still accepts addresses with incorrect endings like .nety<BR><BR>If I remove the &#124[a-z][a-z] bit at the end then it rejects .nety, but doesn&#039;t allow for .uk<BR><BR>I&#039;m converting the string to lowercase before testing so uppercase doesn&#039;t matter.<BR><BR>Thanks<BR><BR>John

5. Junior Member
Join Date
Dec 1969
Posts
3

## RE: Strict email address checking

I&#039;m using this and it seems to work okay...<BR>"^[w.&#039;-]+@[w-]+.([w.-]+.w{2,3}&#124w{2,3})\$"<BR><BR>Good luck.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•