Quantcast
Channel: How can I validate an email address using a regular expression? - Stack Overflow
Browsing all 89 articles
Browse latest View live

Answer by Cees Timmerman for How can I validate an email address using a...

I'm still using:^[A-Za-z0-9._+\-\']+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$But with IPv6 and Unicode coming up, perhaps:^\w[^@\s]*@[^@\s]{2,}$is best. Gmail already allows sequential dots, but Microsoft...

View Article


Answer by FLY for How can I validate an email address using a regular...

hmm strange not to see this answer already within the answers. Here is the one I've build.It is not a bulletproof version but it is 'simple' and checks almost...

View Article


Answer by Mohit Gupta for How can I validate an email address using a regular...

AS per my understanding most probable will cover by../^([a-z0-9_-]+)(@[a-z0-9-]+)(\.[a-z]+|\.[a-z]+\.[a-z]+)?$/is

View Article

Answer by Rinke for How can I validate an email address using a regular...

Quick answerUse the following regex for input validation:([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|"([]!#-[^-~ \t]|(\\[\t...

View Article

Answer by TombMedia for How can I validate an email address using a regular...

I've been using this touched up version of your regex for a while and it hasn't left me with too many surprises. I've never encountered an apostrophe in an email yet so it doesn't validate that. It...

View Article


Answer by Prasad for How can I validate an email address using a regular...

If you are fine with accepting empty values (which is not an invalid email) and are running PHP 5.2+, I would suggest:static public function checkEmail($email, $ignore_empty = false) { if($ignore_empty...

View Article

Answer by Josh Stodola for How can I validate an email address using a...

Per the W3C HTML5 spec:^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$Context:A valid e-mail address is a string...

View Article

Answer by SimonSimCity for How can I validate an email address using a...

As you're writing in PHP I'd advice you to use the PHP build-in validation for emails.filter_var($value, FILTER_VALIDATE_EMAIL)If you're running a PHP version lower than 5.3.6, please be aware of this...

View Article


Answer by Hans-Peter Störr for How can I validate an email address using a...

I would not suggest to use an regex at all - email addresses are way too complicated for that. This is a common problem so I would guess there are many libraries that contain a validator - if you use...

View Article


Answer by grosser for How can I validate an email address using a regular...

This rule matches what our postfix server could not send to.allow letters, numbers, -, _, +, ., &, /, !no -foo@bar.comno...

View Article

Answer by Murthy Jeedigunta for How can I validate an email address using a...

public bool ValidateEmail(string sEmail){ if (sEmail == null) { return false; } int nFirstAT = sEmail.IndexOf('@'); int nLastAT = sEmail.LastIndexOf('@'); if ((nFirstAT > 0) && (nLastAT ==...

View Article

Answer by Mac for How can I validate an email address using a regular...

Here's the PHP I use. I've choosen this solution in the spirit of "false positives are better than false negatives" as declared by another commenter here AND with regards to keeping your response time...

View Article

Answer by AZ_ for How can I validate an email address using a regular...

According to the official standard, RFC 2822, a valid email regex...

View Article


Answer by Eric Schoonover for How can I validate an email address using a...

For the most comprehensive evaluation of the best regular expression for validating an email address please see this link; "Comparing E-mail Address Validating Regular Expressions"Here is the current...

View Article

Answer by Evan Carroll for How can I validate an email address using a...

This regex is from Perl's Email::Valid library. I believe it to be the most accurate, and it matches all 822. And, it is based on the regular expression in the O'Reilly book:Regular expression built...

View Article


Answer by BalusC for How can I validate an email address using a regular...

Not to mention that non-Latin (Chinese, Arabic, Greek, Hebrew, Cyrillic and so on) domain names are to be allowed in the near future. Everyone has to change the email regex used, because those...

View Article

Answer by Abigail for How can I validate an email address using a regular...

It’s easy in Perl 5.10 or newer:/(?(DEFINE) (?<address> (?&mailbox) | (?&group)) (?<mailbox> (?&name_addr) | (?&addr_spec)) (?<name_addr> (?&display_name)?...

View Article


Answer by Jay Zeng for How can I validate an email address using a regular...

No one mentioned the issue of localization (i18), what if you have clients coming from all over the world? You will need to then need to sub-categorize your regex per country/area, which I have seen...

View Article

Answer by SLaks for How can I validate an email address using a regular...

You should not use regular expressions to validate email addresses.Instead, in C# use the MailAddress class, like this:try { address = new MailAddress(address).Address;} catch(FormatException) { //...

View Article

Answer by MichaelRushton for How can I validate an email address using a...

RFC 5322 standard:Allows dot-atom local-part, quoted-string local-part, obsolete (mixed dot-atom and quoted-string) local-part, domain name domain, (IPv4, IPv6, and IPv4-mapped IPv6 address) domain...

View Article
Browsing all 89 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>