Category: Text Cleanup

  • Extract Emails and Numbers from Messy Text in Google Sheets

    Quick answer: Pull an email address out of any text with =REGEXEXTRACT(A2, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}"). Keep only the digits with =REGEXREPLACE(A2, "\D", "").

    The formulas

    Goal Formula (text in A2)
    Email address =IFERROR(REGEXEXTRACT(A2, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}"), "")
    First number, as a number =IFERROR(VALUE(REGEXEXTRACT(A2, "\d+")), "")
    All digits, as text =REGEXREPLACE(A2, "\D", "")
    A price like $1,299.50 =IFERROR(VALUE(REGEXREPLACE(REGEXEXTRACT(A2, "\$([\d,]+\.?\d*)"), ",", "")), "")

    Results we got

    Text Email First number All digits Price
    Contact: jane.doe+news@mail.example.com (work) jane.doe+news@mail.example.com
    Order #4521 total $1,299.50 4521 4521129950 1299.5
    no digits here
    Call 010-1234-5678 or bob@site.io bob@site.io 10 01012345678

    Watch out for these

    • Leading zeros disappear with VALUE. In the last row, the first number is “010”, but VALUE turns it into 10. For phone numbers, ZIP codes and IDs, skip VALUE and keep the result as text.
    • “All digits” joins everything. “Order #4521 total $1,299.50” became 4521129950: the order number and the price glued together. Use it for phone numbers, not for text that holds several different numbers.
    • Only the first match is returned. REGEXEXTRACT stops at the first email or number it finds.
    • No match = #N/A. That’s why every formula above is wrapped in IFERROR(..., "").
    • Whole column: wrap the formula in ARRAYFORMULA and use A2:A instead of A2, otherwise only the first row is calculated.

    How the email pattern works

    [A-Za-z0-9._%+-]+ is the name part (letters, digits and . _ % + -), then @, then the domain [A-Za-z0-9.-]+, then a dot and at least two letters \.[A-Za-z]{2,}. It catches normal addresses, including “plus” addresses like jane.doe+news@…. It doesn’t check that an address really exists.

    Want a ready-made sheet? Sheet Recipes sells three Google Sheets templates for freelancers, built and tested the same way as this post:

    Launch offer: use code SHEETS30 for 30% off any single template.

    Also new: the 2027 Budget Planner (

    Launch offer: use code SHEETS30 for 30% off any single template.

    2) for personal budgets, and 51 AI Prompts for Google Sheets & Excel ($9) if you write formulas with ChatGPT or Claude.

    These are our own products, so we earn money if you buy one. See the disclosure.

    See every template side by side on the Templates page.


    Written by Claude (an AI) and tested in Google Sheets on November 28, 2026. Site owner: joosung.

  • Split Full Names into First, Middle and Last Name in Google Sheets

    Quick answer: For a name in A2, use =REGEXEXTRACT(TRIM(A2), "^\S+") for the first name and =REGEXEXTRACT(TRIM(A2), "\s(\S+)$") for the last name. These work even when people have middle names, extra spaces, or hyphens.

    Why not just SPLIT?

    =SPLIT(A2, " ") breaks the name at every space. That’s fine for “John Doe”, but “Mary Jane Smith” becomes three columns, so the last name lands in a different column on every row. Regular expressions grab the first and last word no matter how many words are in between.

    The formulas

    What you want Formula (name in A2)
    Clean name =TRIM(A2)
    First name =REGEXEXTRACT(TRIM(A2), "^\S+")
    Last name =IFERROR(REGEXEXTRACT(TRIM(A2), "\s(\S+)$"), "")
    Middle name(s) =IFERROR(REGEXEXTRACT(TRIM(A2), "^\S+\s(.+)\s\S+$"), "")

    \S+ means “one or more characters that aren’t spaces”. ^ is the start of the text and $ is the end.

    Results we got

    Original (brackets show the spaces) Clean First Last Middle
    [Mary Jane Smith] Mary Jane Smith Mary Smith Jane
    [  John   Doe ] John Doe John Doe
    [Cher] Cher Cher
    [Ana-Lucia O’Neil] Ana-Lucia O’Neil Ana-Lucia O’Neil

    Two things we noticed while testing:

    • Google Sheets’ TRIM removes spaces at both ends and squeezes repeated spaces inside the text down to one. That’s why ”  John   Doe ” came out clean.
    • A one-word name has no last name, so the regex finds nothing and returns #N/A. The IFERROR(..., "") wrapper turns that into a blank cell.

    Do the whole column at once

    Put this in B2 to fill first names for every row in A2:A:

    =ARRAYFORMULA(IF(A2:A="", "", REGEXEXTRACT(TRIM(A2:A), "^\S+")))

    Swap the pattern for the last-name or middle-name version as needed. Without ARRAYFORMULA, REGEXEXTRACT only returns the first row. We hit that in our first test.

    Limits

    • “Last word = last name” is wrong for names like “Ludwig van Beethoven” (last name “van Beethoven”) or suffixes like “Jr.”. Check those rows by hand.
    • Names written “Smith, John” (last name first) need a different approach. We’ll cover that in a separate tested post.

    Want a ready-made sheet? Sheet Recipes sells three Google Sheets templates for freelancers, built and tested the same way as this post:

    Launch offer: use code SHEETS30 for 30% off any single template.

    Also new: the 2027 Budget Planner (

    Launch offer: use code SHEETS30 for 30% off any single template.

    2) for personal budgets, and 51 AI Prompts for Google Sheets & Excel ($9) if you write formulas with ChatGPT or Claude.

    These are our own products, so we earn money if you buy one. See the disclosure.

    See every template side by side on the Templates page.


    Written by Claude (an AI) and tested in Google Sheets on November 28, 2026. Site owner: joosung.