2つの文字のあいだのテキストを取り出す:Excel と Google Sheets

MID と FIND で 2 つの印のあいだを取り出します。Price is $12.50 today ではドル記号のあと、次の空白の前が 12.50。SKU-[103]-west では角括弧のあいだが 103。start(hello)end では丸括弧のあいだが hello でした。2 つ目の FIND には開始位置を渡し、手前の空白に当たらないようにします。

目次

要点

MID と FIND で 2 つの印のあいだを取り出します。Price is $12.50 today ではドル記号のあと、次の空白の前が 12.50。SKU-[103]-west では角括弧のあいだが 103。start(hello)end では丸括弧のあいだが hello でした。2 つ目の FIND には開始位置を渡し、手前の空白に当たらないようにします。

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

確認のポイント

印がないと FIND は #VALUE! で、IFERROR を付けると no markers here は none です。TEXTBEFORE と TEXTAFTER はこのファイルでは #NAME? で、Excel 365 の関数です。REGEXEXTRACT は [0-9]+.[0-9]+ で 12.50、SKU 行の [0-9]+ で 103 を返しましたが、start(hello)end に [a-z]+ を使うと hello ではなく start になります。

注意点と互換性

列に分割するだけなら SPLIT の記事を見てください。MID と FIND は Microsoft の説明どおり Excel でも使えますが、今回はデスクトップ Excel では再テストしていません。

英語の詳細例・数式・著者メモ

Which versions this applies to

The results below were measured in Google Sheets on November 12, 2026. MID and FIND are in Excel as well, per Microsoft. TEXTBEFORE and TEXTAFTER are documented for Excel 365; in this Sheets file they returned #NAME?, same as in #NAME? Error. REGEXEXTRACT is the Sheets function I also ran; Microsoft documents a REGEXEXTRACT for Excel 365, which I did not re-test in desktop Excel today.

MID and FIND between two markers

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

On Price is $12.50 today that returned 12.50. The start is one character after the $. The length is the distance from that $ to the next space, minus one, so the space itself is not included. The third argument of the second FIND is a start position: I passed the position of $ so the space I hit is the one after the price, not the space in Price is.

Between brackets, on SKU-[103]-west:

=MID(A3,FIND("[",A3)+1,FIND("]",A3)-FIND("[",A3)-1)

That returned 103. Parentheses worked the same way: start(hello)end returned hello.

If the markers are missing, FIND returns #VALUE! (see FIND vs SEARCH). I wrapped that case with IFERROR(...,"none"), and no markers here returned none.

REGEXEXTRACT, and why I still start with MID

A simple pattern for the price also worked: REGEXEXTRACT(A2,"[0-9]+\.[0-9]+") returned 12.50. REGEXEXTRACT(A3,"[0-9]+") returned 103 from the brackets line.

A loose letter pattern does not mean “between the parentheses.” REGEXEXTRACT("start(hello)end","[a-z]+") returned start, the first run of letters, not hello. If you want the text between two specific characters, write that into the pattern, or use MID/FIND, which already did it.

I had an earlier pattern for a capturing group around the dollar amount that returned #N/A or #REF! after I over-escaped it through the API, so I am not quoting that broken pattern. The two simple patterns above, and the MID formulas, are the ones I actually got clean results from.

Excel and Google Sheets differences

In current Excel, Microsoft documents TEXTBEFORE and TEXTAFTER, which would make this extraction shorter. They are not available in this Google Sheets file (#NAME?). MID and FIND are the overlap I ran and that you can use in both products. SPLIT is a different job — breaking every delimiter into columns — and is in Split Text by Delimiter.

Common mistakes

  • Using the first space in the cell as the end marker when a space also appears before the start marker. Pass a start position to FIND so it looks after the $.
  • Pasting TEXTBEFORE into Google Sheets. It returned #NAME? in this file.
  • Using REGEXEXTRACT with [a-z]+ and expecting the text inside parentheses. It returned start from start(hello)end.
  • Leaving FIND unwrapped on a cell with no markers. That is #VALUE!; IFERROR returned none here.

FAQ

How do I extract text between two characters in Google Sheets?

MID plus two FIND calls is the formula I ran. Between $ and the next space it returned 12.50; between [ and ] it returned 103.

Does TEXTBEFORE work in Google Sheets?

Not in this file. TEXTBEFORE(TEXTAFTER(A2,"$")," ") returned #NAME?.

Why did REGEXEXTRACT return start instead of hello?

The pattern [a-z]+ takes the first run of letters. In start(hello)end, that is start. Use MID/FIND around the parentheses, or a pattern that names those parentheses, if you want hello.

What if one of the characters is missing?

FIND returns #VALUE!. IFERROR(...,"none") returned none on a cell with no brackets.

Will MID and FIND work in Excel?

Yes, according to Microsoft. I did not re-run these exact strings in desktop Excel today. For Excel 365, TEXTBEFORE/TEXTAFTER is the newer path I did not test there.

Live-test findings

Google Sheets, November 12, 2026. MID/FIND on Price is $12.50 today returned 12.50; on SKU-[103]-west returned 103; on start(hello)end returned hello. IFERROR of the bracket formula on no markers here returned none. REGEXEXTRACT with [0-9]+\.[0-9]+ returned 12.50; with [0-9]+ on the SKU line returned 103; with [a-z]+ on start(hello)end returned start. TEXTBEFORE/TEXTAFTER returned #NAME?.

Sources

Oscar

表計算の数式とトラブル解決を紹介。検証環境と未確認事項は各記事を参照。

Tested in Google Sheets, November 12, 2026. Excel version notes follow Microsoft documentation and were not re-tested in a desktop Excel workbook on this date..

次の記事:データの整形と入力 TEXTJOIN と CONCAT:Excel と Google Sheets での使い分け