Going Stellar

Home/Google Sheets reference

Google Sheets function · Text

SEARCH in Google Sheets: syntax and examples

SEARCH returns the position where a piece of text first appears inside another text, counting from 1. The match ignores case and accepts the wildcards * and ?. When nothing is found it returns #VALUE!, so wrap it in ISNUMBER or IFERROR.

Syntax

SEARCH(search_for, text_to_search, [starting_at])

Arguments

ArgumentTypeRequiredWhat it does
search_fortextyesThe text to find. It may contain * (any run of characters) and ? (one character).
text_to_searchtextyesThe text to look in.
starting_atnumbernoPosition to start from, counted from 1. Default is 1.

Examples

The examples use this table, starting in A1:

OrderNote
INV-2041-ROUrgent: call the client
inv-2042-bgRefund approved
INV-2043-ROShip on Monday
=SEARCH("-", A2)

Result: 4

Position of the first hyphen in an order code.

Run in a Google Sheet (English US locale) on .

=SEARCH("ro", A2)

Result: 10

The match ignores case: lowercase "ro" finds the uppercase RO at the end.

Run in a Google Sheet (English US locale) on .

=SEARCH("c*t", B2)

Result: 9

Wildcard: from a c up to the next t.

Run in a Google Sheet (English US locale) on .

=SEARCH("-", A2, 5)

Result: 9

Start at position 5 to find the second hyphen.

Run in a Google Sheet (English US locale) on .

=ISNUMBER(SEARCH("refund", B3))

Result: TRUE

A yes or no test: a number means found, an error means not found.

Run in a Google Sheet (English US locale) on .

Common errors

  • Not found gives #VALUE!, not 0. Test with ISNUMBER(SEARCH(...)) or wrap in IFERROR.
  • * and ? are wildcards. SEARCH("?", A2) matches the first character. To look for a literal one, write ~? or ~*.
  • starting_at below 1 or past the end of the text returns #VALUE!.
  • The match ignores case. When case matters, use FIND, which is case-sensitive and has no wildcards.

Compared with Excel

Same syntax and behavior as Excel SEARCH, wildcards included.

Questions and answers

What is the difference between SEARCH and FIND?

SEARCH ignores case and understands wildcards. FIND is case-sensitive and treats * and ? as plain characters.

Sources

  1. SEARCH (Docs Editors Help)

Markdown version · All functions