We’re going to jump straight to the short answer and take care of the long-winded explanation after.

Quite simply—no.

I can hear the developers and the devils advocates out there questioning our blunt denial of regex email validation, prompting the further question, then, of why it exists at all.

Well, we’re not going to deny it can be a useful tool, and it’s certainly a clever little bit of kit to prevent users from adding any old text into a form or other executable medium. At one point, email regex had its part to play in how we gather email data.

But now? In line with current tech and standards?

We say it’s had its day.

If you want to ensure you’re getting clean email addresses that aren’t going to mess with your email marketing, your bounce rates, deliverability scores, and all the things that you know you need to keep your metrics high and your conversions rolling in, then regex isn’t the way.

What is email validation regex?

Regex is short for regular expression; it’s a term used in various coding languages. Regex, or regular expressions, refers to encoded text strings designed to match patterns found in other strings.

They can be quite handy when a user needs to match a string of characters to a particular type of pattern to verify that the supplied information appears correct. Consider phone numbers, ZIP codes, dates, and yes, the big one we’re concerned with—email addresses.

With a simple pattern, an exact string can be matched to a set of rules. When simple patterns become more complicated, regex becomes less efficient and more likely to deliver bad results.

It sounds good so far—so, what’s the problem with regex email validation?

As nifty a tool as regex is, it doesn’t cover the checks you need. Have a look at these:

[email protected]
[email protected]
[email protected]
[email protected]

Let’s say that you spot any one of the above as additions to your email list; you’d flag them straight away (or you should!). You wouldn’t believe any of them were valid entries by real people showing an interest in your product and service.

Regex email validation would, though. It’d let them all through.

Why? Because those obviously fake addresses still follow the patterns its rules set out to confirm.

It’s not looking quite so smart now, is it?

It’s too restrictive

Despite those previous examples looking so obviously false to us, some email formats include far more special characters than we’re used to seeing.

In its simplest form and email address follows the following format:

username@domain

Email addresses are constructed in three sections:

  • The local part – typically a username or job role
  • The @ character
  • The domain, including a valid TLD (Top Level Domain)

If that was all the code had to look for, then a typical javascript regex check would prevent plenty of bad contacts from ending up in our lists.

Typically, our email addresses can include the following characters:

  • Digits: 0 to 9
  • Lowercase and uppercase letters: a to z and A to Z
  • Additional special characters: !#$%&’*+-/=?^_`{|}~
  • The dot character [.]: But not as the first or final character, or used consecutively

If someone were to apply to your email list with any or a range of those special characters, most of us would question whether something was amiss, and we’d be wrong to—they’re all permitted under the current convention.

Regex doesn’t check anything other than syntax

Developers might only be concerned with getting valid-looking addresses through a form, but we’re not. We need to know:

  • Does the domain exist?
  • Is there an MX record to prove the domain has a mail server?
  • Has the email address got a working email account?

Any of those questions that score a ‘no’ will get a hard ‘no’ from us as marketers, too. Regex doesn’t check for any of that—only a dedicated email validation tool will pull up such red flags.

It doesn’t spot temporary and disposable addresses

As email marketers, another thing we’re more than aware of is that plenty of users set up fake temporary accounts to take advantage of an offer, promotion, or other situation. It’s an easy way to avoid adding clutter to their existing email accounts or giving away any information about themselves they don’t want to.

It’s easy to set up a temporary or disposable email address as a one-off solution. Those addresses often disappear within 10 or 15 minutes of being set up, making them incredibly fit for purpose.
Regex won’t check for those. Temporary and disposable email addresses pass all of the regex validation tests.

How would you set up an email regex javascript?

If you’re a dab-hand developer, you probably won’t need our basic grasp of the subject to tell you how, but for those of you with some experience in coding, it should look something like this:

function ValidateEmail(inputText)

{

var mailformat = [a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

if(inputText.value.match(mailformat))

{

alert(“This is not a valid email address”);

return false;

}

}

The part that’s doing all the heavy lifting is the var mailformat line. The execution and characters in that long line of code define what’s allowed and what isn’t.

You can spot the simple stuff: a-z, A-Z, 0-9, and then the special characters in the first, local section. The +@ then dictates the local and domain separator. Following the @ we’ve then got another array of instructions about what’s permissible for the domain section.

If you want a much deeper insight into what it takes to implement a regex validator, then head over to abstract. They’ve got a really good guide into precisely what it takes and are experts when it comes to all kinds of API additions and inclusions.

If a job’s worth doing, it’s worth doing well—so validate your lists the best way possible

There’s only one way to make sure your email lists are in premium condition, and that’s to use a dedicated email validation tool—like Bouncer.

Regex validation could be responsible for letting fake email addresses into your email lists as well as blocking valid ones. When it comes to adding an authentication method to your online forms or data collection methods, we’d suggest other, more robust forms of validation.

Ultimately, running your email lists through a platform like Bouncer is the best way by far to keep your lists clean and healthy, your bounce rates down, your deliverability high, and your sender score in tip-top shape.

Email Message Regex FAQ

What is a simple regex for email validation?

A simple regex (regular expression) for email validation is a sequence of characters that defines a search pattern for email addresses. It can be used to check if a string matches the standard format of an email address. However, it’s important to note that a simple regex might not catch all invalid email addresses and may allow some non-standard email formats to pass through.

How does email regex help in filtering out invalid email addresses?

Email regex is used to match the input string (the email address entered by a user) against a specific format. If the email address doesn’t match this format, it’s considered invalid. This can help prevent typos, ensure data consistency, and protect against certain types of injection attacks.

What is a whitespace character in the context of email regex?

A whitespace character in email regex refers to any character that is used to represent blank spaces, like spaces, tabs, or line breaks. In the context of email addresses, whitespace characters are typically not allowed, and their presence would make an email address invalid.

What is a complex email regex?

A complex email regex is a more detailed and precise regular expression used for email validation. It can account for various aspects of email addresses, such as domain names, non-Latin characters, and specific rules about where certain characters can appear. While it provides a more thorough validation, it can also be more challenging to implement and maintain.

How does email regex handle non-Latin characters and Unicode?

Handling non-Latin characters and Unicode in email regex can be complex. Some email systems allow for Unicode or non-Latin email addresses, but they are not universally supported. A complex email regex can include character classes to match non-Latin characters, but it’s essential to understand the specific requirements and constraints of the email system you’re working with.

What is the role of character classes in email regex?

Character classes in email regex define a set of characters that can match any single character in the input string. For example, the character class [a-z] matches any lowercase English letter. Character classes can be used to specify valid characters for different parts of an email address.

What are the limitations of email regex for email validation?

While email regex can catch many common errors in email addresses, it’s not a complete validation method. Some invalid addresses may still pass a regex check, and some valid addresses may fail, especially if they use less common formats or characters. For thorough email validation, it’s often recommended to use email validation services or to send a confirmation email to the entered address.

Go for in-depth email verification, go for Bouncer