Function Problems

Extract Text Between a Prefix and the Last Hyphen in Excel

Aamir Naveed AkramAamir Naveed Akram Dec 2, 2026 869 views

Question details

Extract the text after a fixed FOUND_ prefix and before the last hyphen in a cell.

Extract Text Between a Prefix and the Last Hyphen in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A cell contains text such as FOUND_video06s-connect-stories, with a fixed prefix and multiple hyphens.
Observed behavior
The desired result is video06s-connect: everything after FOUND_ and before the final hyphen.
Before you start

Check that the source text starts with FOUND_ and contains at least one hyphen after the prefix. The formula below assumes the source is in A2 and uses @ as a marker that must not appear in the source text.

Solution 1Recommended

Use MID and SUBSTITUTE to find the last hyphen

Use this formula to extract the text when the source contains one or more hyphens.

The formula temporarily replaces the last hyphen with @, finds its position, and extracts the text starting immediately after the six-character FOUND_ prefix.

1
Enter the source text

Enter or locate the source string in cell A2, for example, FOUND_video06s-connect-stories.

2
Enter the formula

Select an empty cell and enter =MID(A2,7,FIND("@",SUBSTITUTE(A2,"-","@",LEN(A2)-LEN(SUBSTITUTE(A2,"-",""))))-7), then press Enter.

3
Check and fill the result

Confirm that the example returns video06s-connect. To process more rows, drag the formula cell's fill handle down.

Use MID and SUBSTITUTE to find the last hyphen
Choose a unique marker: If the source text can contain @, replace both occurrences of @ in the formula with another character that does not appear in the source, such as |.
Work with text in WPS Spreadsheets

Extract Text Before the Last Hyphen in WPS Spreadsheets

Use the MID and SUBSTITUTE formula in WPS Spreadsheets to extract text after FOUND_ and before the last hyphen.

  1. 1. Open your spreadsheet: Open WPS Spreadsheets and use File > Open to select your workbook.
  2. 2. Check the source cell: Locate the text in A2, or adjust the formula's cell references to match your source cell.
  3. 3. Enter the extraction formula: Select an empty cell and enter =MID(A2,7,FIND("@",SUBSTITUTE(A2,"-","@",LEN(A2)-LEN(SUBSTITUTE(A2,"-",""))))-7), then press Enter.
  4. 4. Copy the formula: Check the result and drag the formula cell's fill handle down to extract text from additional rows.
Extract text from strings containing multiple hyphens.Open and edit Microsoft Excel XLSX and XLS files.Fill the formula down to process multiple rows.Work with a familiar spreadsheet interface.
microsoft office alternative - wps office

Frequently Asked Questions

What does the formula return for FOUND_video06s-connect-stories?

It returns video06s-connect, removing the FOUND_ prefix and the final hyphen plus the text after it.

What if my source text contains an @ character?

Replace both @ characters in the MID and SUBSTITUTE formula with a marker that does not occur in the source text, such as |.

What happens if there is no hyphen after the prefix?

The formulas require a hyphen after FOUND_. If there is none, they return an error rather than an extracted value.

Can I use a shorter formula in Excel?

Yes. If your Excel version supports TEXTAFTER and TEXTBEFORE, enter =TEXTBEFORE(TEXTAFTER(A2,"FOUND_"),"-",-1) in an empty cell.