On 2011-08-10 Jeroen Geilman wrote: > On 2011-08-10 09:20, Troy Piggins wrote: >> 2. Can you recommend a better or more elegant solution to the second >> part of the table with the /us...@mydomain.com/ etc? I tried using >> something like this: >> >> /(user1)@mydomain.com/ \1_s...@mydomain.com >> >> but it occurred to me that the variable \1 to the right is probably >> not recognised outside the actual pattern within the //. Correct? > > It is not a variable expansion. Use this instead: > > /(user1)@mydomain.com/ $1_s...@mydomain.com > > Read http://www.postfix.org/pcre_table.5.html, section Text > Substitution for details. > > Note that this offers zero advantage over an exact match.
Unless you're using wildcards/alternatives in the group, that is. /(user1|user2|user3)@mydomain.com/ $1_s...@mydomain.com /(foobar-.+)@mydomain.com/ $1_s...@mydomain.com I'd also suggest anchoring the expression on both sides, and escaping the dot in the domain name: /^(.+)@mydomain\.com$/ $1_s...@mydomain.com Otherwise the expression might inadvertently match other addresses as well (like f...@mydomain1com.net). Yes, not very likely in this context, I know, but I prefer to keep regular expressions as exact as possible. It helps avoiding problems where you least expect them. Regards Ansgar Wiechers -- "Abstractions save us time working, but they don't save us time learning." --Joel Spolsky