16

I use Gmail and I'm receiving lots of emails I want to filter. They all have in common that the subject is like these:

Some words - r1234 - Some more words
Some words - r987665 - Some more words
Some words - r01 - Some more words

So, all of them have something like - r... - in the subject...

Is there any way to filter all those messages?

  • 5
    Unfortunately, Gmail doesn't support regular expressions, but you could look into some of the other solutions that answer provides. – John Bensin Sep 23 '13 at 11:23
  • What if you search for "Some words - r" " - Some more words"? – MrWhite Sep 23 '13 at 14:10
  • @w3d I don't understand what you mean... – MikO Sep 24 '13 at 11:29
  • 1
    Ah, do "Some words" and "Some more words" vary each time? In that case my suggestion wouldn't work. I perhaps wrongly assumed that these two phrases were consistent among these emails? (Also, just realised that gmail doesn't seem to like searching for part words, so "wor" wouldn't find "word"!) – MrWhite Sep 24 '13 at 15:08
11

Googles help article 7190 lists the search operators you can use in Gmail. This article lists the AROUND keyword mentioned by RADA.

Currently, using the * (SHIFT 8) also works. I use it as *=AnyTextHere.

e.g. "Ticket* for user" find Ticket 1 for user and Ticket 2 for user and Ticket 1000 for user.

| improve this answer | |
  • This not working for me in to search eg to:(some_id*@some.email) – Nam G VU Dec 2 '19 at 1:57
  • 2
    The original question was about filtering on the subject line. You are trying to filter on the to: field. Using to:*@some.email or to:@some.email works. Your request to use to:string*@some.email does not. Maybe Google uses To & From fields differently than the Subject? – Altered-Ego Dec 3 '19 at 6:13
  • Thanks for clear explain @IanC. Using AROUND works nicely now. – Nam G VU Dec 3 '19 at 6:24
4

For Gmail filtering you first need to construct the "Search Operators." Although it's not a regular expression, you can still achieve what you want.

Some words - r1234 - Some more words

Would be something like "Some words AROUND 1 Some more words"

Find messages with words near each other. Use the number to say how many words apart the words can be

AROUND

Example: holiday AROUND 10 vacation

Add quotes to find messages in which the word you put first stays first.

Example: "secret AROUND 25 birthday"

Here is the official help

I ended up here because I was trying to reduce the number of separate filters I had and wanted to group them together. After reading the reference my messages are all clean.

from:("Twitter" OR "Facebook")

| improve this answer | |
3

Short answer

Gmail doesn't include search features such wildcards or regular expressions.

Alternatives

Use the Gmail API, Google Apps Script or third party application that include search features like wildcards or regular expressions.

References

Search in Gmail - Gmail Help

| improve this answer | |
2

Filtering "From" with:

*@someemail.com OR *@someothermail.com

Works for me.

| improve this answer | |
  • 1
    Question is about doing it with regular expression on subjects. – reducing activity Jun 27 '18 at 14:22
1

You can achieve this with google's AROUND keyword.

For example, I have a filter set up to delete emails with the subject line like "Your December 2018 Transaction History". To match any change in dates, I've set the subject to "Your AROUND Transaction History". It works perfectly.

| improve this answer | |
0

I haven't tried regex, but the current help doc specifies (with examples) the operators you can use to filter search results.

https://support.google.com/mail/answer/7190?hl=en

| improve this answer | |
-2

I just want to update this post since it has incorrect (or outdated ) information. Gmail does support wildcards. I have the following wildcard set up for subject Privacy Policy ...and it works great. I don't want those words to apply to body since it can be at the bottom of most emails.

Like so: * Privacy Policy *.

| improve this answer | |
  • I think you'll find that "subject:privacy policy" works just as well. It's still not wildcard support. – ale Dec 6 '19 at 23:32
  • Just to clarify, I'm talking about setting filters not searching. But you are right about not needing the *. I just added Privacy Policy and it found it even when they were NOT the first words in the subject. I could swear it would not work the first time I tried it. Maybe it took a minute to update. Also so people do not get confused, GMAIL adds "subject:" on its own when using the setup screen. – Carl Shepard Dec 8 '19 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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