---
title: "Check the domain of an email address by regex"
author: "Phil Bainbridge"
date: 2021-08-03T10:28:51+00:00
modified: 2021-08-03T18:52:36+00:00
canonical_url: https://pulse.appsscript.info/p/2021/08/check-the-domain-of-an-email-address-by-regex/
markdown_url: https://pulse.appsscript.info/p/2021/08/check-the-domain-of-an-email-address-by-regex.md
categories:
  - "Beginner"
  - "Sheets"
  - "Snippet"
  - "Solutions"
tags:
  - "pbainbridge.co.uk"
featured_image: https://pulse.appsscript.info/files/2021/08/Email-domain-regex.png
description: "The following Google Apps Script is designed to use a regular expression (regex) to confirm if an email address domain matches one we specify eg: @hotmail.co.uk, @gmail.com, @outlook.com"
---

# Check the domain of an email address by regex

![Check the domain of an email address by regex](https://pulse.appsscript.info/files/2021/08/Email-domain-regex.png)

> Compare a number of email addresses and check their domains against one you are filtering for via a regular expression.
> Screenshot of email addresses in a Google Sheet cell

The following Google Apps Script is designed to use a regular expression (regex) to confirm if an email address domain matches one we specify eg: @hotmail.co.uk, @gmail.com, @outlook.com

I developed the code so I could screen email addresses to make sure they only came from within the institution – otherwise it would have broken the tool I was developing for creating Zoom meetings. The email addresses in this example are all stored in one cell in a Google Sheet and are separated via a comma and a single space.

Source: *[The Gift of Script: Check the domain of an email address by regex*](https://www.pbainbridge.co.uk/2021/08/check-domain-of-email-address-by-regex.html)

---

*Published by [Phil Bainbridge](https://pulse.appsscript.info/p/author/phillipbainbridge/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2021/08/check-the-domain-of-an-email-address-by-regex/](https://pulse.appsscript.info/p/2021/08/check-the-domain-of-an-email-address-by-regex/)*
