Find and Replace with Wildcard in Google Sheets

Wildcards can be a staple when it comes to customizing searches in any Google workplace application. So today, we will answer a few questions and discuss a few points focusing on whether we can use Find and Replace with a wildcard in Google Sheets.


How to Find and Replace with Wildcard in Google Sheets

What are Wildcards?

Wildcards are special characters or symbols used to fine-tune your searches in Google Sheets. Within a function, these symbols represent characters or strings. In Google Sheets, we have three different wildcard characters:

  1. Asterisk (*): This wildcard can represent any number of characters. For example, ‘Bill*’ can mean Bill, Bills, Billy, Billiards, etc.
  2. Question Mark (?): This wildcard represents only a single character. For example, ‘B?ll’ can mean Ball, Bell, Bill, etc.
  3. Tilde (~): This wildcard symbol is usually used before either the * or ? wildcards. It tells Google Sheets that it should consider the next character as a regular character symbol and not a wildcard. For example, ‘b~*’ means to search for all strings that contain the exact text b*.

Can you use Wildcards in Google Sheets?

Yes, you can. Wildcard symbols in Google Sheets are used in certain situations:

  • They’re commonly used in conditional functions. For example, COUNTIF, COUNTIFS, SUMIF, SUMIFS, etc.
  • Wildcards are used to perform partial string lookups in VLOOKUP.
  • They’re used to conditionally filter data.

using wildcard with countif - find and replace with wildcard in google sheets

Using asterisk wildcard to count all instances of IT in the ID column regardless of the ID number.


Can you use Wildcards in Find and Replace?

No, you cannot. Unfortunately, fine-tuning searches using wildcards are not supported in the Find and Replace dialogue box in Google Sheets. Find and Replace will simply ignore the fact that a wildcard is implemented and see it as a regular character to search. The dialogue box also does not have any options for wildcards to check.

you cannot use wildcards in find and replace in google sheets

However, Find and Replace does support Regular Expressions to fine-tune searches here. It is also safe to say that we can customize our searches beyond the limitations of wildcards using regular expressions.


1. Fine Tune Find and Replace with Regular Expressions in Google Sheets

What are Regular Expressions?

Regular expressions are a sequence of symbols or characters that we used to represent other characters and strings. Regular expression symbols are also known as ‘metacharacters’. The following is a list of these metacharacters and what they mean:

CharacterMeaning
^The beginning of the string
$The end of the string
.A single character
?Zero or one occurrence of a character or string
*Zero or more occurrences of a character or string
+One or more occurrences of a character or string
|The Or operator
()This holds a group of metacharacters inside it and represents that sequence of characters
[]This holds a set of characters and represents any one of the characters inside it
[^]This holds a set of characters and represents any one of the characters not listed inside it
\This is used to escape a special character

Now that we understand what regular expressions are and what they can do, let’s use them in our dataset to find all the instances that start with the letters ‘IT’ in the ID column. Much like what we did with COUNTIF using wildcards in the previous section.

Using Regular Expressions to Find and Replace Partial String Matches

In the Find and Replace dialog box (Keyboard shortcut: CTRL+H, or find it from the Edit tab), set up the following search conditions:

  • Search for ‘^IT’. This regular expression searches for all the cells that start with the letters “IT”.
  • Search over a Specific range. We have included only the ID column, C3:C12.
  • Check the Search using regular expression option. You must enable this option to get the correct result.

conditions in find and replace in google sheets with regular expressions

Click Find to cycle through all the instances that match:

find and replace with regular expression animated

As you can see, Find and Replace has found all four instances where the values start with the letters IT using regular expression. This is correct as we have seen the same count number previously with COUNTIF and wildcards.

The Find and Replace option is only half as useful if we are only searching. So let’s replace all the values containing IT we have found with the word “ENG” to update the ID.

replacing values with regular expression in find and replace

For a more in-depth breakdown of the Find and Replace function covering more scenarios, please see our Find and Replace in Google Sheets article.

Read More: How to Use Find and Replace in Column in Google Sheets


Similar Readings


2. Using REGEXREPLACE Formula to Find and Replace Values in Google Sheets

Another way to find and replace in Google Sheets using regular expressions is by using the REGEXREPLACE formula. As the name suggests, the function searches for values using regular expressions and replaces them with something user-defined.

The REGEXREPLACE syntax:

REGEXREPLACE(text, regular_expression, replacement)

the regexreplace function syntax

Where the Find and Replace option replaces the searched value within its existing cell, the REGEXREPLACE function does the same in another cell. Users can take advantage of this to keep the original data unchanged and secure.

Let’s use REGEXREPLACE to replace all the IDs that start with “IT” with “ENG”.

Our formula:

=REGEXREPLACE(C3,"^IT","ENG")

using regexreplace function to find and replace partial text in google sheets

Read More: Use REGEXREPLACE to Replace Multiple Values in Google Sheets (An Easy Guide)


Final Words

While you can’t use wildcards in Find and Replace, you can use regular expressions in it to achieve virtually the same results. Where wildcards are limited to three symbols, regular expressions can take a step further to further fine-tune your searches with a combination of characters called metacharacters. That’s not to say how it can be fully taken advantage of in REGEX functions like REGEXREPLACE.

Please feel free to leave any queries or advice you might have for us in the comments section below.


Related Articles

Mehrab Imtiaz

Mehrab Imtiaz

Mehrab Imtiaz is a Technical Writer for officewheel.com specializing in everything Google Sheets. Mehrab has always had a profound passion for writing and with his experience with MS Excel and Google Sheets throughout his career, it seems to be a great match when it comes to dishing out tips and tutorials for all to enjoy.

2 Comments
  1. Hi.

    So how do I, for example, make ABC-123 into ABC. In excel you just replace “-*” with nothing and voila you get ABC. Can you do the same in Google Sheets and if you do – how?

    Thanks

    • Hi Max,
      I am assuming that you are thinking about extracting the letters ABC from ABC-123. In this case, you can approach it in two ways without even using wildcards.
      The first way is to use text functions to extract the number of characters from the string:

      =LEFT(B2,LEN(B2)-4)

      The LEN(B2)-4 removes the last 4 characters from the string.
      For a more dynamic approach, you can look for the hyphen/dash as a delimiter to remove characters before or after it. In this case, to get ABC from ABC-123, the formula will be:

      =MID(B2,1,FIND(“-“,B2)-1)

      Just replace “-” with any delimiter of your choosing.
      However, if you still want to extract using regular expression to get ABC from ABC-123, use this:

      =REGEXREPLACE(B2,”[0-9-]”,””)

      The regular expression to remove all digits and hyphens is given by [0-9-].
      I hope this helps!

Leave a reply

OfficeWheel
Logo