Extract Text Between Two Characters

Excel Formulas › Text

Excel 365Legacy altMID/FIND

To pull out the text between two markers — the value inside parentheses, a code between slashes — Excel 365 nests TEXTAFTER and TEXTBEFORE; older versions use the classic MID + FIND combination.


Quick formula: to get the text inside parentheses in A2:
=TEXTBEFORE(TEXTAFTER(A2, "("), ")")
TEXTAFTER grabs everything after the “(”; TEXTBEFORE then trims off everything from the “)” onward, leaving just the middle.

Functions used (tap for the full reference guide):

The example

Pull the code from inside the parentheses.

AB
1TextInside ( )
2Order (A123) readyA123
3Item (B-7) okB-7

The formula

The text between the parentheses:

=TEXTBEFORE(TEXTAFTER(A2, "("), ")") // "Order (A123) ready" → "A123"

How it works

Two slices, inside out:

  1. TEXTAFTER(A2, "(") returns everything after the opening bracket — "A123) ready".
  2. TEXTBEFORE(…, ")") then keeps everything before the closing bracket — "A123".
  3. Nesting them isolates exactly what sits between the two markers.
  4. Use different markers ("/", "[", ":") for other wrappers.

Pre-365? The MID/FIND version does the same: =MID(A2, FIND("(",A2)+1, FIND(")",A2)-FIND("(",A2)-1) — start one character after the “(” and take as many characters as sit before the “).”

Try it: interactive demo

Live demo

Type text with a bracketed part and pick the wrapper characters.

Between:

Variations

Legacy MID + FIND

Any version:

=MID(A2, FIND("(",A2)+1, FIND(")",A2)-FIND("(",A2)-1)

Between two of the same character

Text between the 1st and 2nd slash:

=TEXTBEFORE(TEXTAFTER(A2, "/"), "/")

After the last marker

Use a negative instance number:

=TEXTAFTER(A2, "/", -1)

Pitfalls & errors

#N/A or #VALUE! when a marker is missing. If the text has no “(” or “),” the functions error. Wrap in IFERROR for messy data.

FIND is case-sensitive; SEARCH isn’t. For letter markers where case might vary, swap FIND for SEARCH in the legacy formula.

Multiple brackets. The simple nest grabs the first pair. For a later pair, target the right instance with TEXTAFTER’s instance argument.

Practice workbook

📊
Download the free Extract Text Between Two Characters practice workbook
Bracketed strings with the live MID/FIND extraction, the TEXTAFTER/BEFORE and slash variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I extract text between two characters in Excel?
In Excel 365 nest the two functions: =TEXTBEFORE(TEXTAFTER(A2, "("), ")"). In older versions use =MID(A2, FIND("(",A2)+1, FIND(")",A2)-FIND("(",A2)-1).
How do I get the text inside parentheses?
Use =TEXTBEFORE(TEXTAFTER(A2, "("), ")") to grab everything between the opening and closing parenthesis.
What if some cells don't have the markers?
The functions return an error when a marker is missing. Wrap the formula in IFERROR to return a blank or default for those rows.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Split text into columns · Extract numbers from text · Find and replace text

Function references: TEXTBEFORE · TEXTAFTER · MID · FIND