Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dozen or so SVN projects that generate a few dozen email messages every day, each with subject line like this "[SVN projectname] in branch/trunk list of files".

I want to send these email messages to a folder automatically (for weekly review), but if somebody sends me a comment regarding an SVN commit (which typically has subject line "Re: [SVN projectname] ...") then I don't want to send the message to the folder, since it is likely to require immediate action.

My question is: what is the best way to address this gmail filtering requirement?

Simply specifying a gmail filter that sends messages with subject [SVN projectname] to a folder is too general, because such a filter will take both the messages that I want to filter and some (like the Replies mentioned above) that I don't want filtered. I would describe the "pattern" I want like this:

/^\[SVN projectname\]/

I am aware that full regular expression filter support is both resource intensive and prone to security holes, which is why I've chosen the example (which is real, by the way) carefully - the "left anchor" pattern is the easiest and most efficient (to implement) type of text matching pattern that I can think of (except maybe a check on minimum/maximum string length).

I am also aware that I can use the "From" filter (and in some cases the "To" filter) to distinguish between messages which are automatically generated by SVN and messages which are generated by humans (and indeed, that is my current "workaround" for the fact that I cannot use a better filtering pattern for the subject line). But IMO this is not a real solution, because it means that I must tweak my mail filtering rules each time we change the hosting location of an SVN repository, for example - and if I write filters based on "To" then I need to tweak them when we change our email aliases.

Indeed, the very existence of "To" and "From" filters in gmail acknowledges that email headers contain metadata which naturally calls for "fielded search" as opposed to the "(free) text search" which works so well for the message body. But in order to dissect the elements of an email workflow we need pattern matching which is sensitive enough to distinguish between an "original" message and a "reply", and it has been standard email client behavior for many years to encode this in the construction of the subject line. So it seems silly that we cannot take advantage of this fact when writing our gmail filters.

share|improve this question

migrated from stackoverflow.com Jul 18 '11 at 14:10

This question came from our site for professional and enthusiast programmers.

I don't think this is a good question for SO. – Qtax Jul 8 '11 at 13:12
Could you please explain why not? – Peter Jul 8 '11 at 13:44
(Just sounded to me like a "why doesn't application X have feature Y?" question, where X is not programming/development related anyway. But never mind.) – Qtax Jul 8 '11 at 14:21
I tried posting a Gmail feature request here but have heard only deafening silence. I know Gmail users have been fruitlessly clamoring for generic regex support (when filtering SMTP header values) for years, now. But what I'm asking for is much more specific, and much easier to implement. – Peter Sep 6 '11 at 1:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.