How do I create a Gmail filter to search for text only at the beginning of the subject line?

We get regular auto-build messages from Jenkins build servers at work.

It would be nice to take them to a shortcut by skipping the inbox.

Using a filter is, of course, the right choice.

The desired identifier is the [RELEASE] at the beginning of the subject line.

Attempting to specify any of the following regular expressions results in emails with the string release in any case being on any subject line:

 \[RELEASE\]* ^\[RELEASE\] ^\[RELEASE\]* ^\[RELEASE\].* 

From what I read later, Gmail does not have standard regex support, and from experiments, it seems, like with Google searches, special characters are simply ignored.

Therefore, I am looking for a search parameter that can be used, perhaps something like atstart:mystring according to their notation has: in:

Is there a way to force a match only if it occurs at the beginning of a line and only if square brackets are included?

Sincere thanks.

+85
filter regex gmail subject
Sep 03 '12 at 11:01
source share
4 answers

Regex is not in the list of search functions , and it was included (more or less, as a function of better message search (for example, wildcard and partial word search)) a list of pre-programmed function requests , so the answer is: β€œyou cannot do this via the web Gmail ": (

There are no current Labs features that offer this. SIEVE filters would be another way to do this, so it was not supported , it seems that there will no longer be any final SIEVE support statement in Gmail help.

Updated for the rot link. The pre-configured list of feature requests was, er isned, the original is on archive.org from 2012, now you just get redirected to a foggy page telling you how to give feedback. The lack of support for SIEVE was addressed in answer 78761 Does Gmail support all IMAP functions ?, because for some time in 2015, which responds quietly and redirects the client configuration to the IMAP response, the .org archive has a copy from 2014.

In the case when the current brackets are used for grouping to search for any form () {} [] , they do not have an observed effect, if only one member is inside. Using (aaa|bbb) and [aaa|bbb] equivalent and will find the words aaa or bbb . Most other punctuation characters, including \ , are treated as a space or word separator, + - : and " have special meanings, but see help .

You can search for regular expressions on your inbox (within limits) programmatically through Google docs: http://www.labnol.org/internet/advanced-gmail-search/21623/ contains a source showing how this can be done ( copy the document, then Tools > Script Editor to get the full source).

You can also do this through IMAP, as described here: Python IMAP search for partial threads and script something to move messages to another folder. The IMAP SEARCH verb only supports substrings, not regular expressions (Gmail searches are further limited to full words, not substrings), additional match processing is required to apply the regular expression.

For completeness, one last workaround: Gmail supports plus addressing, if you can change the destination address to youraddress+jenkinsrelease@gmail.com , it will still be sent to your inbox, where you can filter by the recipient's address. Remember to filter using your full email address to:youraddress+jenkinsrelease@gmail.com . This, of course, is more or less the same as setting up a dedicated Gmail address for this purpose :-)

+123
Feb 04 '13 at 13:23
source share

This Google Script app can do what you want:

https://github.com/paoloantinori/gmail-labeler

which marks and filters Gmail streams using the basic RegEx, against the body or email headers.

+2
Mar 10 '17 at 15:40
source share

The only option I have found for this is to find the exact wording and place it under the "Has words" option. This is not the best option, but it works.

0
Aug 12 '16 at 15:21
source share

I was wondering how to do it myself; it seems that Gmail has quietly performed this function since then. I created the following filter:

 Matches: subject:([test]) Do this: Skip Inbox 

And then I sent a message with a subject

 [test] foo 

And the message has been archived! Thus, it seems that all that is needed is to create a filter for the subject prefix that you want to process.

-5
Jan 24 '14 at 4:54 on
source share



All Articles