103

Is wildcard search possible in Gmail?

0

8 Answers 8

43

Not in general, no.

The Gmail search functionality works based on what I would describe as tokens. A token is any sequence of alphanumeric characters separated by a space or by other non-alphanumeric characters such as underscore, full stop (period), "@", dash, etc.. So in [email protected] there are 4 tokens: "peter", "ford23", "example" and "com".

Wildcards within tokens do not work. Wildcards outside of tokens are unnecessary and misleading.

Imagine you wish to find messages from [email protected] and tried these examples:

from:(pete*)

... would not work

from:(ford23@*)

... would work, but is misleading. It is no different from searching for "from:ford23".

If you thought that Gmail was checking for the "@" symbol immediately after "ford23", you could try this instead ...

from:(peter@*)

... should not work, but does!

`

One example given in another answer is

subject:(jefferson-*)

... but again, Gmail is inadvertently misleading us. The dash and asterisk characters have no effect. (You can remove them and then remove the brackets too. It's the same as searching for "subject:jefferson".) It would return an email with subject "meeting with jefferson.jones".

subject:(jefferso*)

... would not return an email with subject "jefferson-school"

subject:(jefferso*-*)

... would not return an email with subject "jefferson-school"

`

There has been a suggestion that Perl regex can be used. I will not address that suggestion here, except to repeat that wildcards within tokens do not work (even using Perl syntax). And wildcards outside of tokens are unnecessary and misleading.

`

Disclaimer: For the sake of brevity I have used uncertainty-free language above. But I do not work for Google and I am not 100% sure of every claim in this answer. I do believe it is one of the best answers so far though. Google's own Gmail search operators help page doesn't mention wildcards.

1
  • I'm not sure how I'm supposed to interpret "from:(ford23@*) would work, but is misleading" combined with "from:(peter@*) should not work, but does". Are you basically saying that you have no idea why those are interpreted differently? Or are those interpreted the same? Or are you trying to suggest that numbers are treated differently from letters in this case?
    – NotThatGuy
    Mar 22, 2022 at 17:45
30

You can use Perl regex in both the find and filters if you wrap it in a forward slash.

from:(/(\@hp\.com$)/)

Will match everything from the hp.com domain.

It gets complicated very quickly because you have to escape certain characters.

Here's one I use that matches multiple address and compresses several rules down to one:

from:(/(^(discship|info)\@netflix\.com$)|(\@(engage|email)\.xbox\.com$)/)
Apply filter Media

That will label notification emails matching:

[email protected]
in[email protected]
[email protected]
[email protected]
20
  • 13
    Has anyone been able to get this to work? I'm using Google Apps, and it doesn't seem to work in either the filter or search. The only reason it does seem to work is because google discards symbols so your query from:(/(hp\.com$)/) is becoming from:@hp.com. The reason | works is because it acts as the OR operator. @Turtle: do you have any links to documentation of the feature?
    – Senseful
    Jul 9, 2010 at 17:06
  • 23
    Unfortunately, this doesn't work. Tested on both Gmail and Google Apps.
    – Senseful
    Aug 29, 2010 at 3:50
  • 5
    I am not able to get this to work either. Sep 23, 2012 at 22:21
  • 11
    This is misleading. The only regex-like special characters that are respected by Gmail search are parentheses (for grouping) and the pipe ('OR' operator). @ToddProuty This example works because all the other symbols/punct serve as term separators, no different from spaces. Here is another example that works: from:(/($(engage|email)\.\/xbox^com)/). Jan 1, 2015 at 19:22
  • 5
    Does not work. This answer should be voted way down. I tried ^n.*[email protected]$ and it did not work. Other commenters are right about the reason. 'Tis a sad day. Mar 27, 2018 at 19:12
18

No, it is not possible. However, it depends on what you need it for. Gmail uses a very limited form of stemming based on whole words.

For example, let's see if I can retrieve emails from [email protected]

from:phwd - works

from:pwhd.l - nope

from:phw - nope

So the closest you will get in this case is if the person was nice enough to cut their first name and last name by the period.

so [email protected] will result in all of the above searches not working.

But say I was nice to fill out my contact information and have my display name as "phwd lastname" then I can at least retrieve it this way

from:"phwd"

from:"phwd lastname"

It sucks but at least we have Gmail Ninjas.

2
16

According to Berkeley Lab Commons:

Gmail search does not implement sub-string, partial word, wildcard, or regular expression searching.

Your only alternative is narrowing things down with Advanced Search or trying multiple, simultaneous options in the search box

3
  • 2
    +1 thanks Ivo for that, sometimes I have some misspelled words in emails and was hoping for some solutions for this. I will leave the question open for another day in case someone come with a work around solution for this
    – kristof
    Jul 8, 2010 at 16:59
  • How funny! I work at Berkeley Lab and I was an early adopter for the Berkeley Lab Google Apps implementation, and I was part of the discussion behind that FAQ. I have a slightly different take. See my answer below. Nov 11, 2013 at 16:55
  • The link now seems broken Aug 9, 2019 at 9:35
6

Wildcards are not officially supported in Gmail, even if they are supported in Google Search.

That said, I have been using wildcards to match hostnames and subject lines, and I have been doing this for 5+ years. However, since wildcards are an unsupported feature, the behaviour changes from time to time. Filters that once worked will stop working after Google changes Gmail. In addition, filters used with Gmail in Google Apps may work differently then filters in standard Gmail (outside of Google Apps).

The following examples work for me in Gmail for Google Apps.

For example, until Oct 2012 I was able to use the following search to match emails sent with the from line of "[email protected]" or "example@*.example.org" (where the latter was an email sent directly from [email protected], for example).

from:([email protected] OR example@*.example.org)

But in October 2012 this filter suddenly broke. But now I can use the following search with the same results:

from:example*example.org

Also, I can use a wildcard in the subject line. The following filter will match emails with a subject like: [jefferson-school-pta] Important information from school principal:

subject:(jefferson-*)
2
  • 2
    As per my answer, I believe that searching for subject:(jefferson-*) is the same as searching for subject:jefferson so any apparent success with wildcards is a red herring.
    – Peter Ford
    Oct 8, 2014 at 1:42
  • Perhaps the algorithm has changed, but at the time of my email, subject:(jefferson-*) and subject:jefferson would return different results. ``subject:jefferson` would not match jefferson-school-pta. Oct 8, 2014 at 3:45
3

A bit easier, just write the following in the search box:

from: (*@mysite.com)
3
  • While this is correct for full pre-domain searches, it isn't a true wildcard meaning that [email protected] wouldn't get found from a search like from:(word*@domain.com). Oct 22, 2012 at 18:20
  • 2
    As per my answer, I believe the * and @ do not have the intended (or any) effect. So this search will match against everything you expected it to, and potentially against some extra stuff.
    – Peter Ford
    Oct 8, 2014 at 1:38
  • from:(*@aliexpress.com) matches an email from [email protected] so it does not really work nowadays Aug 9, 2021 at 22:46
2

I know it's not the most straightforward solution, but with Mozilla Thunderbird asterisk wildcard will work. For example, searching *top* will find anything containing partially or totally that string, for example, Stop or TopGun.

https://commons.lbl.gov/display/google/Gmail+workarounds+for+sub-string+(partial+word)+search

1
  • 1
    this should be the accepted answer... it's a shame that still in 2022 Google didn't implemented wildcard search! Nov 29, 2022 at 14:04
0

No, it's not possible.

The search in Gmail does not allow substring search.

1
  • 4
    Adding a link to backup your claim will help. Oct 23, 2012 at 0:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.