Learn

Platform

For Business

Pricing

Resources

data analytics lesson video

data analytics lesson video

data analytics lesson video

How to Extract Text After a Character in Excel and Google Sheets

How to Extract Text After a Character in Excel and Google Sheets

How to Extract Text After a Character in Excel and Google Sheets

In this article you will learn a reliable technique for extracting the portion of a text string that comes after a specific character, like a dash or at sign, using RIGHT, SEARCH and LEN. This method works in both Excel and Google Sheets and handles variable-length trailing text. It is ideal for analysts, spreadsheet users, and anyone cleaning or transforming text data.

Interested in learning more? Continue learning with

Interested in learning more? Continue learning with

Excel Formulas & Functions

Excel Formulas & Functions

What You'll Learn / Key Take-Aways

- How to extract the characters to the right of a delimiter using a combination of RIGHT, SEARCH and LEN.

- Why SEARCH by itself can produce the wrong result when used with RIGHT, and how LEN fixes that.

- Practical formulas you can paste into Excel or Google Sheets and adapt to emails, IDs, and other delimited text.

- Edge cases to watch for and how to handle missing delimiters or multiple occurrences.

## Why this technique matters

All right. When you need everything after a delimiter, like pulling a short ID after a dash or the domain after an at sign, you cannot rely on returning a fixed number of characters. The portion after the delimiter often varies in length. The cleanest, most reliable approach is to calculate how many characters remain after the delimiter and then ask RIGHT to return exactly that many.

This is a small mathematical trick that unlocks a lot of real world data cleaning tasks.

## The core idea in plain language

1. Use SEARCH (or FIND) to find the position of the delimiter from the left. SEARCH returns the character index of the delimiter within the string.

2. Use LEN to get the total length of the entire string.

3. Subtract the position of the delimiter from the total length to get the number of characters after the delimiter.

4. Use RIGHT with that calculated number to extract the trailing text.

In formula form:

- =RIGHT(A2, LEN(A2) - SEARCH("-", A2))

This tells the spreadsheet: take the whole string in A2, figure out how many characters remain after the dash, and return that many characters from the right.

## Step-by-step examples

### Example 1. Extract the short ID after a dash

Imagine a column U with values like:

- ABC-123

- XY-4567

- LONGPREFIX-89

To get the short id after the dash in the cell U2 use:

=RIGHT(U2, LEN(U2) - SEARCH("-", U2))

Notes:

- SEARCH("-", U2) returns the position of the dash counting from the left.

- LEN(U2) is the full length.

- LEN(U2) - SEARCH("-", U2) equals the number of characters after the dash.

When you apply this down the column it adapts automatically for three, four, or any number of trailing characters.

### Example 2. Extract the email domain after the at sign

If you have an Email column and want the email service, use the same pattern:

=RIGHT(A2, LEN(A2) - SEARCH("@", A2))

Applied to rows like "jane.doe@gmail.com" this returns "gmail.com". It works consistently even when usernames vary in length.

## Differences between SEARCH and FIND

- SEARCH is case insensitive and supports wildcards.

- FIND is case sensitive and does not support wildcards.

Either will work for locating a delimiter like "-" or "@". Use SEARCH if you want case insensitivity or wildcard support. Use FIND if you need case sensitivity.

## Handling missing delimiters and errors

If the delimiter might be missing, SEARCH and FIND return an error. Wrap the formula to avoid ugly errors or to provide a fallback.

- Simple blank on error:

=IFERROR(RIGHT(A2, LEN(A2) - SEARCH("-", A2)), "")

- Or return the whole string if there is no delimiter:

=IFERROR(RIGHT(A2, LEN(A2) - SEARCH("-", A2)), A2)

This keeps your sheet tidy and predictable.

## When the delimiter appears multiple times

The SEARCH function finds the first occurrence from the left. If your delimiter can appear multiple times and you want everything after the last occurrence, you need a different approach.

A common trick is to replace the last occurrence with a unique marker using SUBSTITUTE, then find that marker. Here is a formula pattern to get the text after the last dash:

=RIGHT(A2, LEN(A2) - FIND("~", SUBSTITUTE(A2, "-", "~", LEN(A2) - LEN(SUBSTITUTE(A2, "-", "")))))

How this works in summary:

- LEN(A2) - LEN(SUBSTITUTE(A2, "-", "")) gives the count of dashes.

- SUBSTITUTE(A2, "-", "~", count) replaces the last dash with a unique character ~.

- FIND("~", ...) gives the position of that last dash.

- The remainder follows the same LEN minus position logic.

This is more complicated, but it is the reliable way when you need the last delimiter rather than the first.

## Additional Tips, Pitfalls to Avoid & Pro Advice

- Trim spaces first: leftover leading or trailing spaces change LEN and can break your result. Use TRIM(A2) inside the formula when needed.

- Watch for nonstandard characters: lookalike characters or invisible control characters can confuse SEARCH. CLEAN and TRIM help.

- Use IFERROR to handle rows without the delimiter. It makes spreadsheets look professional and avoids propagation of errors.

- If speed matters on very large sheets, keep formulas simple. Overly nested SUBSTITUTE operations can slow recalculation.

- If your delimiter is special in SEARCH because you use wildcards, escape it or use FIND instead.

## FAQ

Q: How do I extract text after the last dash in a string?

A: Use a SUBSTITUTE trick to replace the last dash with a marker then FIND that marker. Example:

=RIGHT(A2, LEN(A2) - FIND("~", SUBSTITUTE(A2, "-", "~", LEN(A2) - LEN(SUBSTITUTE(A2, "-", "")))))

Q: What if some rows do not contain the delimiter? The formula returns an error.

A: Wrap the formula with IFERROR to return a blank or a fallback value. Example: =IFERROR(RIGHT(A2, LEN(A2) - SEARCH("-", A2)), "")

Q: Can I use these formulas in both Excel and Google Sheets?

A: Yes. RIGHT, LEN, SEARCH, FIND, SUBSTITUTE and IFERROR exist in both Excel and Google Sheets and behave the same for these use cases.

Q: Should I use SEARCH or FIND?

A: Use SEARCH for case insensitive matching or if you need wildcards. Use FIND when you require case sensitivity. For locating simple delimiters like "@" or "-" either will work.

Q: How do I remove extra spaces before applying these formulas?

A: Wrap the cell reference with TRIM, for example: =RIGHT(TRIM(A2), LEN(TRIM(A2)) - SEARCH("-", TRIM(A2))). This ensures consistent length calculations.

Q: Is there a faster way if I only need the domain from many email addresses?

A: The LEN minus SEARCH approach is efficient and readable. For massive data sets, consider extracting in a separate column and converting formulas to values once cleaned to speed up recalculation.

## Summary of Key Points / Take-Home Messages

- To get text after a delimiter, calculate how many characters are left and feed that to RIGHT.

- Formula pattern: RIGHT(cell, LEN(cell) - SEARCH("delimiter", cell)).

- Use IFERROR and TRIM to handle missing delimiters and stray spaces.

- For the last occurrence of a delimiter use SUBSTITUTE to mark the final instance before extracting.

If you practice these patterns you will be able to combine text functions to solve almost any extraction problem. Stay curious and experiment with combining SEARCH, LEN, RIGHT and SUBSTITUTE to fit your data.

FOR INDIVIDUALS

Master modern data skills

Start learning for Free. No credit card required. Master skills in data literacy, Excel, Power BI, SQL, Python and more.

FOR COMPANIES & TEAMS

Train your team in data

Create your team account today, request a demo, or start with a team assessment today.

FOR INDIVIDUALS

Master modern data skills

Start learning for Free. No credit card required. Master skills in data literacy, Excel, Power BI, SQL, Python and more.

FOR COMPANIES & TEAMS

Train your team in data

Create your team account today, request a demo, or start with a team assessment today.

FOR INDIVIDUALS

Master modern data skills

Start learning for Free. No credit card required. Master skills in data literacy, Excel, Power BI, SQL, Python and more.

FOR COMPANIES & TEAMS

Train your team in data

Create your team account today, request a demo, or start with a team assessment today.