RegEx

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

RegEx

Postby theLizard » Mon Dec 21, 2015 8:08 pm

Does anyone know of the current implementation for validating email addresses using RegEx

TIA
theLizard
BCBJ Master
BCBJ Master
 
Posts: 449
Joined: Wed Mar 18, 2009 2:14 pm

Re: RegEx

Postby rlebeau » Mon Dec 21, 2015 8:55 pm

The opening page of http://www.regular-expressions.info shows example expressions for validating email addresses:

But you can do much more with regular expressions. In a text editor like EditPad Pro or a specialized text processing tool like PowerGREP, you could use the regular expression "\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b" to search for an email address. Any email address, to be exact. A very similar regular expression (replace the first "\b" with "^" and the last one with "$") can be used by a programmer to check whether the user entered a properly formatted email address. In just one line of code, whether that code is written in Perl, PHP, Java, a .NET language, or a multitude of other languages.


The page linked to in that paragraph contains a lot more details and gotchas related to using regex to email validate email addresses:

How to Find or Validate an Email Address
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1504
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: RegEx

Postby theLizard » Tue Dec 22, 2015 1:22 pm

Thanks for the link Remy, much appreciated.

Have a Merry Christmas all.
theLizard
BCBJ Master
BCBJ Master
 
Posts: 449
Joined: Wed Mar 18, 2009 2:14 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 17 guests

cron