Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
edited tags
Link
Braiam
  • 4.5k
  • 11
  • 50
  • 83
Used more standard formatting (we have italics and bold on this platform). Added some context.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

How tocan I validate an email address using a regular expression?

Over the years I have slowly developed a regular expression that validates MOSTmost email addresses correctly, assuming they don't use an IP address as the server part.

I use it in several PHP programs, and it works most of the time. However, from time to time I get contacted by someone that is having trouble with a site that uses it, and I end up having to make some adjustment (most recently I realized that I wasn't allowing 4four-character TLDsTLDs).

What is the best regular expression you have or have seen for validating emails?

I've seen several solutions that use functions that use several shorter expressions, but I'd rather have one long complex expression in a simple function instead of several short expression in a more complex function.

How to validate an email address using a regular expression?

Over the years I have slowly developed a regular expression that validates MOST email addresses correctly, assuming they don't use an IP address as the server part.

I use it in several PHP programs, and it works most of the time. However, from time to time I get contacted by someone that is having trouble with a site that uses it, and I end up having to make some adjustment (most recently I realized that I wasn't allowing 4-character TLDs).

What is the best regular expression you have or have seen for validating emails?

I've seen several solutions that use functions that use several shorter expressions, but I'd rather have one long complex expression in a simple function instead of several short expression in a more complex function.

How can I validate an email address using a regular expression?

Over the years I have slowly developed a regular expression that validates most email addresses correctly, assuming they don't use an IP address as the server part.

I use it in several PHP programs, and it works most of the time. However, from time to time I get contacted by someone that is having trouble with a site that uses it, and I end up having to make some adjustment (most recently I realized that I wasn't allowing four-character TLDs).

What is the best regular expression you have or have seen for validating emails?

I've seen several solutions that use functions that use several shorter expressions, but I'd rather have one long complex expression in a simple function instead of several short expression in a more complex function.

Tweaked title, added tag
Link
Steve Chambers
  • 39.8k
  • 29
  • 178
  • 222

Using a regular expression How to validate an email address using a regular expression?

edited tags
Link
Cody Gray
  • 246k
  • 53
  • 511
  • 590
Loading
tag update
Link
dreftymac
  • 32.6k
  • 27
  • 125
  • 191
Loading
Removed the pattern-matching tag
Link
Loading
added tag
Link
Ashraf.Shk786
  • 623
  • 1
  • 11
  • 23
Loading
corrected grammer
Source Link
Ashraf.Shk786
  • 623
  • 1
  • 11
  • 23
Loading
Post Merged (destination) from stackoverflow.com/questions/1903356/…
Edited to remove the really really bad expression that causes people confusion.
Source Link
acrosman
  • 12.9k
  • 10
  • 42
  • 56
Loading
edited tags
Link
Charles
  • 51.5k
  • 13
  • 107
  • 146
Loading
Rollback to Revision 6
Link
Charles
  • 51.5k
  • 13
  • 107
  • 146
Loading
retag question
Link
NeverHopeless
  • 11.2k
  • 4
  • 37
  • 56
Loading
different language environment varies from REGEX syntax.
Link
Loading
Edited Title as per SO's defined standards ("How to"/"How do I" are discouraged)
Link
Ravindra S
  • 6.5k
  • 12
  • 74
  • 111
Loading
edited title
Link
casperOne
  • 74.7k
  • 19
  • 189
  • 262
Loading
Notice removed Reward existing answer by Mark W
Bounty Ended with bortzmeyer's answer chosen by Mark W
Notice added Reward existing answer by Mark W
Bounty Started worth 50 reputation by Mark W
Question Protected by Michael Petrotta
Post Made Community Wiki
edited tags
Link
Ned Batchelder
  • 378.2k
  • 77
  • 583
  • 675
Loading
Source Link
acrosman
  • 12.9k
  • 10
  • 42
  • 56
Loading