[Dovecot] Sieve regex match problem
Andy Howell
AndyHowell at austin.rr.com
Wed Jan 21 23:13:58 EET 2009
I'm trying to make a regex to match common mailing list addresses and file messages to
corresponding folders.
I'm using sieve-test to try and understand what is happening. The sieve script is:
require [ "fileinto", "regex", "variables" ];
if header :regex ["Sender"]
["(.*>[ \\t]*,?[ \\t]*)?([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] {
fileinto "${0} :: 1:${1} 2:${2} 3:${3} 4:${4} 5:${5} 6:${6} 7:${7}";
}
The email contains:
Sender: antlr-interest-bounces at antlr.org
I'm trying to form a folder from the first two parts of the sender. In the real script,
that will do a "fileto antlr.interest;"
Running sieve-test, I get:
* store message in folder: antlr-interest-bounces at antlr.org :: 1: 2:antlr 3: 4:interest
5: 6:-bounces 7:
I don't understand why parts 3 and 5 are empty. From the regex grouping, I expected
Part 2 "antlr"
Part 3 "interest"
Part 4 "-bounces"
The regex groups break done as:
1: (.*>[ \\t]*,?[ \\t]*)? - match leading name, comma or spaces
2: ([^-@]*) - match first part: 'antlr' in his case
- - Hyphen between parts
3: ([^-@]*) - match second part: interest in this case
4: (-bounces)? - When cc'd, -bounces part isn't used
The same regex tested with perl works as I expected.
Without the first group of the regex '(.*>[ \\t]*,?[ \\t]*)?', it works correctly. That
group isn't getting matched anyway, so it shouldn't matter.
This is with 1.2alpha5.
What am I missing?
Thanks,
Andy
More information about the dovecot
mailing list