RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find YAER - Yet Another Email Regex
Expression
^[^\s]+@[^\.][^\s]{1,}\.[A-Za-z]{2,10}$
Description
Simple email regex following some liberal email address validation. Requires non-whitespace name (but allows any other character), an @ symbol, then a non-period character, then some non-whitespace text (but allows just about everything else), and finishes with a tld that is 2 to 10 chars long. Two-characters is the universal minimum, 10 seemed like a good upper limit for now and allows room to grow. You can use this for a quick sanity check. Yes, the user can still enter invalid email addys, but then they won't get their emails, will they?
Matches
Non-Matches
Author Rating: Not yet rated. Major Banzai
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: So close, yet so far...
Name: Asfand Yar Qazi
Date: 3/27/2009 11:48:02 AM
Comment:
Hi, The problem, Randal L. Schwartz, is that the regex you posted will only work in Perl. I use Ruby. I can't for the life of me find a complete regex that actually works in Ruby.


Title: Still wrong
Name: Randal L. Schwartz
Date: 9/21/2007 10:17:03 PM
Comment:
It's *bad* education. You're teaching people to do the wrong thing. It's not whether *I* like it or not... there's only ONE OFFICIAL DEFINITION of an email address, and this regex doesn't match it. Here's one that gets close: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html and as you'll see it's a long longer than this one.


Title: relax
Name: Major Banzai
Date: 6/5/2007 7:36:08 PM
Comment:
I'm sorry, how did you assume that I wanted to submit an RFC822 regex? This site is used for examples, education, and sharing. This regex is valuable to me for my application, and it may help someone else in a similar situation. If you don't need it, please move along quietly.


Title: ORLY ORLY ORLY
Name: Jo3y.com
Date: 6/4/2007 6:17:21 PM
Comment:
Well why don't you read the rfc and post one instead of whining and telling people what to do, Mr. Randal L. Schwartzkopf. Thank you, Mr. Jo3y


Title: WRONG WRONG WRONG
Name: Randal L. Schwartz
Date: 5/31/2007 2:14:51 PM
Comment:
As usual, every SINGLE email regex matcher here has FAILED to read RFC822. As with all the other versions, THIS REGEX IS WRONG. DO NOT USE THIS REGEX. DO NOT. AND PLEASE STOP POSTING BROKEN REGEX TO MATCH EMAIL HERE. {sigh}


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials