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 /[email protected]/ etc? I tried using >> something like this: >> >> /(user1)@mydomain.com/ \[email protected] >> >> 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/ [email protected] > > 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/ [email protected] /(foobar-.+)@mydomain.com/ [email protected] I'd also suggest anchoring the expression on both sides, and escaping the dot in the domain name: /^(.+)@mydomain\.com$/ [email protected] Otherwise the expression might inadvertently match other addresses as well (like [email protected]). 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
