4

Say I have the label Home/Family/Kids and Home/Family, is there any search expression that can match both of these with a single term? For example, I want to use a search query like label:Home/Family*.

Note that using Home/Family/Kids OR Home/Family is not a good solution since I have many labels and this wouldn't be practical.

4
  • No wildcard searching in gmail has long been a major issue. I don't think you have any hope until this is solved. The OR operator is the only workaround, and not a good one. Being Google I'd almost expect regular expressions to work, but they don't.
    – drye
    Jul 9, 2010 at 19:46
  • they do for filters just not the label parameter
    – phwd
    Jul 10, 2010 at 12:57
  • @phwd: I'm guessing you're referring to this answer. Have you been able to get it to work? As far as I can tell it doesn't actually support regexes and instead strips out punctuation and performs a match. (See the comments on that answer for more information.)
    – Senseful
    Jul 10, 2010 at 21:47
  • yea you are right I starting testing with and without the punctuation and it seems to give the same result. I will have to sit down and look it properly tonight
    – phwd
    Jul 10, 2010 at 22:50

4 Answers 4

2

Using the complex OR is annoying, but being the only workaround I suggest you use it with the combination of the Quick Links Lab feature.

Quick Links by Dan P

Adds a box to the left column that gives you 1-click access to any bookmarkable URL in Gmail. You can use it for saving frequent searches, important individual messages, and more.more.

You will be able to save the complex searches and recall them when needed.

1
  • This used to be the correct answer, but Quick Links are no longer available. There is a Chrome Extension that adds that missing feature, but it's local only.
    – Lockszmith
    Jun 3, 2022 at 22:22
2

You can do a wildcard match using Regex within Google Apps Script, which accesses your Gmail. If you want to do a simple search based on a given word as the root, you can use the simpler test() approach.

For example:

  var matchList = [];
  var labelRoot = /Home/
  var existingLabels = GmailApp.getUserLabels();
  for (var i = 0; i < existingLabels.length; i++){
    if (labelRoot.test(existingLabels[i].getName())){
      ++matchCount;
      matchList.push(existingLabels[i]);
    }
  }

This will fetch all Gmail labels which start with "Home" as the root label. (it'll actually match all labels which contain the string "home" anywhere in the label so be careful). You can modify according to your needs.

It'll populate the array matchList with all labels which start with "Home".

You can then do what you want with it: fetch all threads with these labels, delete these labels, etc.

1

You can apply multiple labels to an email. So, you could have the labels Home, Kids, and Pets. Emails regarding your kids could have Home and Kids. Emails regarding your pets could have Home and Pets. Then you could do a search for label:Home. Not exactly what you want, but it works.

3
  • This might work with filters, I'll give it a try, thanks.
    – Senseful
    Jul 9, 2010 at 18:40
  • Nope, it doesn't work :( ... I specifically need it to be hierarchical though, so tagging as multiple labels is not an option for me.
    – Senseful
    Jul 9, 2010 at 18:44
  • Oh. That's all I got, sorry! Jul 9, 2010 at 18:55
0

An alternative for me was to tag the emails with both the parent and children tag. Similar to what @Rebecca Chernoff suggested, but using a hierarchical approach.

eg. I would create two filters, one that tags all emails 'from:@google.com' with 'Internet' and then a second filter that tags the same emails with 'Internet/Search'

This way, you can create the nested labels, and then select 'Internet' for the entire parent category, and you'll see all your emails from all the children tags too.

The more nested levels you have, the more duplicate filters you will need to create.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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