Extract Usernames from Email Addresses in Google Sheets

Published on

Google Sheets provides several methods for extracting usernames from single or multiple email addresses. You can use REGEXREPLACE, REGEXEXTRACT, LEFT+SEARCH, or SPLIT+CHOOSECOLS. We will discuss all these options below.

An email address, or email ID, has three parts: the first part is the username or local_part, followed by the “@” symbol, and finally the domain.

Whichever formula you choose to extract the username from the email address, you need to consider the “@” symbol, the second part of the email address. Because the username is the part before this symbol.

Formulas for Extracting Usernames from Email Addresses in Google Sheets

Assume cell A1 contains an email address. You can use any of the following formulas in another cell to extract the username:

REGEXREPLACE:

=REGEXREPLACE(A1, "@(.*)", "")

This REGEXREPLACE formula matches the “@” symbol followed by any characters (zero or more) until the end of the string and replaces that part with an empty string, leaving only the username.

REGEXEXTRACT:

=REGEXEXTRACT(A1, "([^@]+)")

This formula matches one or more characters that are not the “@” symbol. Since REGEXEXTRACT extracts the first matching occurrence, it returns only the username, not the domain.

LEFT + SEARCH:

=LEFT(A1, SEARCH("@", A1)-1)

The SEARCH function finds the position of the “@” in the string. LEFT extracts characters from the beginning of the email address up to the position of “@” minus one, which gives the username.

SPLIT + CHOOSECOLS:

=CHOOSECOLS(SPLIT(A1, "@"), 1)

The SPLIT function divides the email address at the “@” character, and CHOOSECOLS returns the first column of the result, which is the username.

Step-by-Step Guide

The username part of email addresses can contain alphanumeric characters and special characters such as periods, underscores, hyphens, plus signs, and percent signs.

Consider the following sample email addresses in column A (range A2:A):

simple@example.com
sheets.expert@example.com
my.style.email.with+symbol@example.com
other.email-with-dash@example.com
user.name+tag+sorting@example.com
y@example.com
example-indeed@strange-example.com

To extract usernames from these addresses, enter one of the above formulas in cell B2. For example, using REGEXREPLACE:

=REGEXREPLACE(A2, "@(.*)", "")

This formula will display the username in cell B2. Then, drag the fill handle from B2 down as far as needed to apply the formula to the rest of the cells.

Example of Extracting Usernames from Email Addresses in Google Sheets

Using an Array Formula

Clear any existing formulas in the range B2:B, and enter the following array formula in cell B2. This will extract all usernames from the email addresses in A2:A at once:

=ArrayFormula(REGEXREPLACE(A2:A, "@(.*)", ""))

This array formula will automatically apply to the entire column.

Extract Usernames from a List of Comma-Separated Email Addresses

When you have a list of comma-separated email addresses in a single cell, you might want to extract all the usernames at once. In such cases, you can first split the list by the comma delimiter and then use REGEXREPLACE to extract the usernames.

Since REGEXREPLACE alone does not work with arrays, you’ll need to combine it with ARRAYFORMULA. Additionally, use TEXTJOIN to concatenate the extracted usernames into a comma-separated list.

If your comma-separated email list is in cell A2, use the following formula:

=ArrayFormula(TEXTJOIN(", ", TRUE, REGEXREPLACE(SPLIT(A2, ","), "@(.*)","")))

This formula splits the email addresses in cell A2 by commas, applies REGEXREPLACE to each split email to remove the domain, and then joins the resulting usernames into a single comma-separated list.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

More like this

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.