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:

[email protected]

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 [email protected] 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.

READ MORE
2018 Holiday Email Marketing Guide

Go for in-depth email verification, go for Bouncer