Extract full name from email format using REGEXEXTRACT in Google Sheets

I need help with extracting a complete name from email addresses in Google Sheets. I have email addresses formatted like [email protected] and I want to get the full name as one string.

Currently I’m using this formula:

=REGEXEXTRACT(B2, "(.*)\.(.*) @")

But this only gives me the first part sarah in one cell. I want to combine both parts so I get sarah williams as a single result in one cell. How can I modify my regex pattern to achieve this?

Your regex is almost right - just that space before the @ is breaking it.

Try this:

=REGEXEXTRACT(B2, "(.*)\.(.*?)@")

Captures everything before the dot and between the dot and @, but you’ll get both parts separately.

For the full name in one cell:

=SUBSTITUTE(REGEXEXTRACT(B2, "(.*)@"), ".", " ")

Grabs everything before @ and swaps dots for spaces.

Honestly, if you’re doing this regularly, you’re wasting time with spreadsheets. I use Latenode for email parsing now - handles hundreds instantly.

Set up workflows that process entire lists, extract names, even add extra data. Way better than manual regex.

Check it out: https://latenode.com

The Problem: You’re trying to extract the full name from email addresses in Google Sheets, but your current regular expression only extracts the first part of the name. You have email addresses in the format [email protected] and want to obtain the full name, sarah williams, as a single string in one cell.

TL;DR: The Quick Fix:

Use this formula: =SUBSTITUTE(REGEXEXTRACT(B2, "^([^@]+)"), ".", " ")

This formula extracts everything before the “@” symbol and replaces the “.” with a space, effectively combining the first and last name.

:thinking: Understanding the “Why” (The Root Cause):

Your original formula, =REGEXEXTRACT(B2, "(.*)\.(.*) @"), had an extra space before the “@” symbol in the regular expression pattern. This space prevented the regex from correctly capturing the entire name portion of the email address. The (.*) parts capture any character (.) zero or more times (*), so they greedily capture everything up to the last dot in the string and leave the rest of the name. The corrected regex ^([^@]+) uses a negated character class [^@] to match any character except “@” (+ means one or more times), and the ^ ensures it starts from the beginning of the string. The SUBSTITUTE function then neatly replaces the dots with spaces for the desired output.

:gear: Step-by-Step Guide:

Step 1: Correct the Regular Expression:

Replace your current formula with the corrected one:

=SUBSTITUTE(REGEXEXTRACT(B2, "^([^@]+)"), ".", " ")

This formula will extract the entire name portion from your email address.

Step 2: Test with Different Email Formats:

Test the formula with a variety of email addresses to ensure it handles different name structures correctly (e.g., names with middle initials, names with hyphens).

Step 3: Handle Edge Cases (Optional):

For more complex scenarios or less standard email formats, consider more sophisticated regular expressions or alternative text manipulation functions like SPLIT to break up the name into parts before joining them.

:mag: Common Pitfalls & What to Check Next:

  • Email Address Format: This solution assumes a relatively standard email format. If you have unconventional email addresses, you might need a more robust regular expression. Consider using an online regex tester to refine the pattern if needed.

  • Data Cleaning: Ensure your email addresses in column B are properly formatted and don’t contain unexpected characters or extra spaces.

  • Case Sensitivity: Regular expressions are case-sensitive by default. If you need case-insensitive matching, add the i flag to your regex. However, given the nature of this task, case sensitivity shouldn’t be a major concern.

:speech_balloon: Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!

Yeah, that extra space in your pattern is the problem. Here’s what I use for similar extractions:

=REGEXREPLACE(REGEXEXTRACT(B2, "([^@]+)"), "\.", " ")

This grabs everything before the @ and swaps dots for spaces in one shot. Way more reliable than SUBSTITUTE for complex emails with multiple dots or weird formatting.

I’ve been using this for six months on membership lists - handles most business email formats without issues. Works great even with middle initials like [email protected], gives you clean “john p smith” output.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.