Search and use find and replace

You can find and replace words in a document, spreadsheet, or presentation with Google Docs, Sheets, and Slides. You can also search within a file using the keyboard shortcut Ctrl + f (⌘ + f on a Mac).

Search for dollar amounts

Note: This example only works with Google Sheets.

Enter into "Find": ^\$([0-9,]+)?[.][0-9]+

This string means a dollar amount where the first number is any number 0-9 or comma occurring zero or more times, followed by [.], followed by any number 0-9 repeated one or more times. This search could find numbers like: $4.666, $17.86, $7.76, $.54, $900,001.00, $523,877,231.56.

Search for U.S. zip codes

Enter into "Find": [0-9]{5}(-[0-9]{4})?

This string represents a U.S. zip code consisting of five numbers with an optional hyphen and four-digit add-on.

Search for names that start with a lowercase letter

Note: This example only works with Google Sheets.

Enter into "Find": ^[a-z].*

This string represents a cell with a lowercase letter followed by another character 0 or more times. This search would find: bob, jim, gEORGE, marTin.

Replace with regular expressions

You can replace parts of a regular expression with capture groups. You reference these capture groups in the "Replace" string using the format "$<group number>." Note: Capture groups only work with Google Sheets.

An asterisk after a character represents a search for that preceding character repeated 0 or more times.

do*g

dog, dg, dooog

dOg, doug

+

A plus after a character represents a search for that character displayed 1 or more times.

do+g

dog, dooog

dg, dOg, doug

?

The previous expression is optional.

do?g

dg, dog

dOg, doug

^

A caret must be placed at the beginning of a regular expression. It signifies the string starts with the character(s) or sequence placed after the caret.

Note: This regular expression only works with Google Sheets.

^[dh]og

dog, hog

A dog, his hog

$

A dollar sign must be placed at the end of a regular expression and signifies that the string ends with the character(s) or sequence placed before the dollar sign.

Note: This regular expression only works with Google Sheets.

[dh]og$

dog, hog, hot dog

dogs, hogs, doggy

{A, B}

The previous expression is repeated between A and B times, where A and B are numbers.

d(o{1,2})g

dog, doog

dg, dooog, dOg

[x], [xa], [xa5]

A character set indicates that just one of the given character(s) should occur in the current position. Usually, any characters are valid within brackets, including characters mentioned previously in expressions: [xa,$5Gg.]

d[ou]g

dog, dug

dg, dOg, dooog

[a-z]

A character set range signifies a search for a character within the given range of characters. Common ranges include a-z, A-Z, and 0-9. Ranges can be combined into a single range: [a-zA-Z0-9]. Ranges can also be combined with character sets (mentioned previously): [a-zA-Z,&*].

d[o-u]g

dog, dug, dpg, drg

dg, dOg, dag

[^a-fDEF]

A character set beginning with a ^ signifies a search for a character that is not within the given set.

d[^aeu]g

dog, dOg, dig, d$g

dg, dag, deg, dug

\s

Any white-space character.

d\sg

d g, d[TAB]g

dg, dog,

Share this:

Mary is a Docs & Drive expert and author of this help page. Leave her feedback below about the page.