1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Java Script Tutorials

Comparing E-mail Address Validating Regular Expressions


Conclusion:
Geert De Deckere from the Kohana project has developed a near perfect one:
/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD

Notes:

There's no perfect regular expression to validate e-mail addresses
Table of valid and invalid characters in the local part of an e-mail address
Some characters (like the ampersand, apostrophe, asterisk etc) are technically valid, but can cause problems due to their significance in operating systems, programming languages and applications and therefore shouldn't really be used. I've just used my judgement on whether they should be treated as valid or not.
Some of these are dependent on being executed using case-insenstive regex functions.
This page uses PHP's ereg() and preg_match() functions, but some of these will work with JavaScript and other languages

/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD
http://pastie.textmate.org/159503
Uses preg_match()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org valid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 valid
IPAndPort@127.0.0.1:25 valid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net valid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com invalid
domainEndsWithDash@domain-.com invalid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 17/17
Invalid: 17/19

/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_]+(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i
Warren Gaebel
Uses preg_match()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org valid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel invalid
uncommonTLD@domain.mobi invalid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 valid
IPAndPort@127.0.0.1:25 valid
subdomain@sub.domain.com valid
local@dash-inDomain.com invalid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net valid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com invalid
domainEndsWithDash@domain-.com invalid
TLDDoesntExist@domain.moc invalid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 14/17
Invalid: 18/19

^([a-zA-Z0-9_'+*$%\^&!\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9:]{2,4})+$
My modification of Quirksmode.org regex
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org valid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 valid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: valid
invalid
someone-else@127.0.0.1.26 valid
.localStartsWithDot@domain.com valid
localEndsWithDot.@domain.com valid
two..consecutiveDots@domain.com valid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m valid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 15/17
Invalid: 9/19

^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$
http://www.quirksmode.org/js/mailcheck.html
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 valid
.localStartsWithDot@domain.com valid
localEndsWithDot.@domain.com valid
two..consecutiveDots@domain.com valid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m valid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 13/17
Invalid: 10/19

^[_a-zA-Z0-9-]+[@][a-zA-Z0-9]+[\.](com|net|org){1}$
My original attempt
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum invalid
uncommonTLD@domain.travel invalid
uncommonTLD@domain.mobi invalid
countryCodeTLD@domain.uk invalid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com invalid
local@dash-inDomain.com invalid
dot.inLocal@foo.com invalid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com invalid
domainEndsWithDash@domain-.com invalid
TLDDoesntExist@domain.moc invalid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 6/17
Invalid: 18/19

^([A-Z0-9]+[._]?){1,}[A-Z0-9-]+\@(([A-Z0-9]+[-]?){1,}[A-Z0-9]+\.){1,}([A-Z]{2,4}|museum)$
http://aspn.activestate.com/ASPN/Cookbook/Rx/Recipe/59886
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel invalid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org invalid
singleLetterDomain@x.org invalid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com invalid
domainEndsWithDash@domain-.com invalid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 10/17
Invalid: 17/19

^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$
http://www.regular-expressions.info/email.html
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum invalid
uncommonTLD@domain.travel invalid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com valid
localEndsWithDot.@domain.com valid
two..consecutiveDots@domain.com valid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 11/17
Invalid: 12/19

^[a-z0-9\._-]+@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)$
http://www.zend.com/zend/spotlight/code-gallery-wade5.php?article=code-gallery-wade5&kind=sl&id=1988&open=1&anc=0&view=1#Heading10
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org invalid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com valid
localEndsWithDot.@domain.com valid
two..consecutiveDots@domain.com valid
domainStartsWithDash@-domain.com invalid
domainEndsWithDash@domain-.com invalid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 12/17
Invalid: 14/19

/^[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)+$/i
http://www.webmaster-forums.net/showthread.php?s=314529bbe536c5978d88e308479498e9&p=209363
Uses preg_match()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org valid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 valid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net valid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 valid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m valid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 16/17
Invalid: 13/19

^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$
Used by previous developer in a website I'm working on
Uses eregi()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org invalid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 invalid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net invalid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com invalid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 invalid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m invalid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 13/17
Invalid: 15/19

/^[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*@[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*$/
Philip Helger
Uses preg_match()These should be valid
l3tt3rsAndNumb3rs@domain.com valid
has-dash@domain.com valid
hasApostrophe.o'leary@domain.org valid
uncommonTLD@domain.museum valid
uncommonTLD@domain.travel valid
uncommonTLD@domain.mobi valid
countryCodeTLD@domain.uk valid
lettersInDomain@911.com valid
underscore_inLocal@domain.net valid
IPInsteadOfDomain@127.0.0.1 valid
IPAndPort@127.0.0.1:25 invalid
subdomain@sub.domain.com valid
local@dash-inDomain.com valid
dot.inLocal@foo.com valid
a@singleLetterLocal.org valid
singleLetterDomain@x.org valid
&*=?^+{}'~@validCharsInLocal.net valid

These should be invalid
missingDomain@.com invalid
@missingLocal.org invalid
missingatSign.net invalid
missingDot@com valid
two@@signs.com invalid
colonButNoPort@127.0.0.1: invalid
invalid
someone-else@127.0.0.1.26 valid
.localStartsWithDot@domain.com invalid
localEndsWithDot.@domain.com invalid
two..consecutiveDots@domain.com invalid
domainStartsWithDash@-domain.com valid
domainEndsWithDash@domain-.com valid
TLDDoesntExist@domain.moc valid
numbersInTLD@domain.c0m valid
missingTLD@domain. invalid
! "#$%(),/;<>[]`|@invalidCharsInLocal.org invalid
invalidCharsInDomain@! "#$%(),/;<>_[]`|.org invalid
local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org valid

Valid: 16/17
Invalid: 12/19

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy