On Tue, Feb 10, 2026 at 09:23:13PM +0100, Michael Grimm via Postfix-users wrote:
> > Demo (now just single '$', no longer in main.cf): > > > > $ printf '%[email protected]\n"%s"@demo.example\n' foo "foo bar" | > > postmap -q - 'pcre:{ > > { /"(.*)"@(demo\.example)$/ "bcc=${1}"@db.${2} }, > > { /(.*)@(demo\.example)$/ bcc=${1}@db.${2} } }' > > [email protected] [email protected] > > "foo bar"@demo.example "bcc=foo bar"@db.demo.example > > > > $ printf 'bcc=%[email protected]\n"bcc=%s"@db.demo.example\n' foo > > "foo bar" | > > postmap -q - 'pcre:{ > > { /^"bcc=(.*)"@db\.(demo\.example)$/ "${1}"@${2} } > > { /^bcc=(.*)@db\.(demo\.example)$/ ${1}@${2} } }' > > [email protected] [email protected] > > "bcc=foo bar"@db.demo.example "foo bar"@demo.example > > > > Only downside is that any headers with "db.demo.example" also get > > rewritten by smtp_generic_maps. > > Wow. That's gorgeous and a real regex gem in my point of view. It took > me a while to comprehend. I do really want to thank you for your > efforts. I learned a lot. Sorry to disappoint you, but those are comparatively simple beginner regular expressions. PCRE does not expose many of the more advanced features of Perl's REs. Use of incremental matching when parsing can, for example, be seen in: https://github.com/vdukhovni/postfix/blob/master/postfix/auxiliary/collate/collate.pl?ts=8 > But, as mentioned above, I will keep it simple and thus I will stick > to my virtual_alias_maps approach. Whatever works best for you. There are a few ways to handle this. -- Viktor. 🇺🇦 Слава Україні! _______________________________________________ Postfix-users mailing list -- [email protected] To unsubscribe send an email to [email protected]
