[exim] Re: Show regex capture group in logs?

Startseite
Nachricht löschen
Nachricht beantworten
Autor: MRob
Datum:  
To: exim-users
Betreff: [exim] Re: Show regex capture group in logs?
On 2023-05-16 20:05, Slavko via Exim-users wrote:
> Dňa 16. mája 2023 19:36:00 UTC používateľ MRob via Exim-users
> <exim-users@???> napísal:
>> Hi, I want to capture part of a regex match (capture group) to put in 
>> logs. This example using subject header works but is there a better 
>> way?
>> 
>> warn set acl_c_temp = ${if match{$h_Subject:}{<regex with capture 
>> group>}{$1}{none}}
>>     !condition = ${if eq{$acl_c_temp}{none}}
>>     logwrite = Notice: subject match is: $acl_c_temp
> 
> Empty variable is the same as undefined:
> 
>     set acl_m_temp = ${if match{$h_Subject:}{<regex>}{$1}}
>     condition = ${if def:acl_m_temp}
>     ...


Thanks Slavko!

> Note, use acl_m_... for that, one connection can transfer
> multiple unrelated messages, once acl_c_... will be set,
> it can remain in that state for other messages in the
> same connection (while not in this case, but anyway).
> The acl_m_... will be cleared for every message for you
> by exim itself.


I wasnt sure which is best. In this situation temp variable getting set 
every time *even if set to undefined* correct? So I understand it should 
not matter what variable to use, right?

If you do a few in a row it's not a problem right?

warn set acl_m_temp = ${if match{$h_Subject:}{<regex 1>}{$1}}
      condition = ${if def:acl_m_temp}
      ...
warn set acl_m_temp = ${if match{$h_Subject:}{<regex 2>}{$1}}
      condition = ${if def:acl_m_temp}
      ...
warn set acl_m_temp = ${if match{$h_Subject:}{<regex 3>}{$1}}
      condition = ${if def:acl_m_temp}
      ...


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/