How To Use Search Operators and Wildcards to Search GMail

Did you know you can use advanced search operators and wildcards to search Gmail? Did you know you can use a bunch of specific searches within Gmail to find something specific in a morass of mail? This tutorial shows you how to do it.

How To Use Search Operators and Wildcards to Search GMail

Gmail is one of the most popular freemail providers in the world. Not only does it offer reliable free email services, it also includes a suite of other Google tools, such as Drive, Sheets, Calendar, Photos, and a host of others. As you would expect from the company that created the world’s largest search engine, there is a lot more to Gmail than meets the eye.

Gmail search

Gmail offers the usual search functions, always visible at the top of the page, but it also offers a lot more. Using Regular Expressions, or RegEx for short, you can filter very specifically. For example, you could filter email from a particular address after a particular date, or between a set of dates. Once you get the hang of it, RegEx really is quite powerful.

Regular Expressions work in Gmail and Google Docs, so if you use both of them, this tutorial is going to be doubly useful. In fact, you actually need to use Google Docs to work with RegEx.

  1. Click this link to make a copy of the Gmail RegEx document in your own Google Docs. You will be prompted to make a copy of the file, select to copy it and you will see a Google Sheet like the image above. You should see a Gmail RegEx section in the center and a Gmail RegEx menu item appear.
  2. Select the Gmail RegEx menu item and select Initialize.
  3. Allow permissions for the file when prompted to enable it to work with your Gmail account.

Now that your Gmail RegEx feature is enabled, it is time to play.

The Gmail Label (Cell F3) refers directly to the labels you have configured in your Gmail account. If you decide to move a message from the inbox to another folder, you’re using labels; you can create new ones by clicking on the icon that looks like a file folder with an arrow to the right after you select an email. If you want to search your entire email account, leave the Label as Inbox. If you want to narrow the search, type in the exact label name in place of Inbox.

Add your search operator in Regular Expression (Cell F4), then select the Gmail RegEx menu and select Search Mailbox.

RegEx will search your Gmail account for any email containing whatever you put into Cell F4 and bring them back as a list in the Sheet. You can then select them directly from there.

Search operators and wildcards in Gmail

You don’t have to use RegEx if you don’t want to. You can use simpler search operators within Gmail to find what you’re looking for if you want. In the Inbox view, select the gray arrow next to the search button to expose the full search box. It is from here that you can use operators in Gmail.

You can keep your search operators simple or make them as complex as you like. Gmail works with three types of operators: Boolean, Gmail’s own, and Drive operators. This page on the Google website shows you what is what with search operators. Use one or many of the criteria within this search panel to find your email.

Let’s say you’re looking for an email from someone with an attachment you need. You know roughly when it was sent and by whom but cannot find it.

  • You could try adding the sender’s email address in the From: box.
  • You could try adding the approximate date it was sent by configuring the ‘Date within…’ entry at the bottom.
  • Then hit the blue search button.

If that doesn’t work, close the search panel and go back to the basic search bar. You could type ‘is:unread’ in the search bar to pull only those emails you have yet to read.

If that doesn’t work, try ‘has:attachment’ as in this example we know the email had an attachment.

To save time, you could use a Boolean entry to combine the two into ‘is:unread AND has:attachment’. Remember, the broader the terms you use to search, the more emails you’re going to need to trawl through in order to find the specific one you’re looking for. The more you can narrow it down, the faster you can find what you’re looking for.

Wildcards are slightly different from regular search terms. They are denoted by an asterisk (*) and represent unknown terms in a search. You would add this at the end of a search term to cover random entries.

In the above example, you know that John sent you the email but you don’t know where he works or which email address he used to send it. You could use the search operator ‘John@*’ or ‘John*’ in the From search box to isolate it. The first search assumes the use of a first name and domain email address while the second covers first name and surname domain email address. You get the idea.

4 thoughts on “How To Use Search Operators and Wildcards to Search GMail”

besmart says:
click on tools=> script editor. you will see what he did. You are granting yourself access to your own inbox essentially. The program runs as the user who is running it. If you shared that sheet with someone else and they ran the function it would search their inbox.

if you really are butt hurt about it create your own spreadsheet, copy the stuff over, open the script editor and copy the script over and reload. He made that easy for you though with the button click.

Deen Hameed says:
Hey Amit,

I’d love to try out the RegEx sheet, but pretty leery about giving uncontrolled access to my email account. Why do we have to give any kind of access to a third-party to access and search our own email using a google sheet in our _own_ account? I’m confused…

Would be easier if Gmail had allowed wild-card searches by now – they _ARE_ a search company after all).

Any chance you could put up a how-to to teach us how to build the same RegExp sheet on our own? Thanks for putting up the source code for the sheet (in the help link). The only thing really is how to set up our own worksheet to use the code so we don’t have to allow anyone else access to our emails…

steve says:
copy the sheet, select tools-script editor and copy that too. save.

or hit the button the nice man gave you and it will do that for you.

Geoff says:
The asterisk does not work in Gmail as a wildcard operator.
A says:
This sounds great, but I’m concerned about the security of the Gmail RegEx document you link to. How can I be sure that it won’t give someone else access to my mail?

Comments are closed.

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.

Todays Highlights
How to See Google Search History
how to download photos from google photos