[exim] catching newlines with ${sg {}{}{}}

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Marten Lehmann
日付:  
To: exim-users
題目: [exim] catching newlines with ${sg {}{}{}}
Hello,

I need to extract the value "X-purgate-ID" from $spam_report:

X-purgate: Spam
    X-purgate-ID: 150741::080616223818-6C9786C0-73CE72D8/2129941411-0/0-3
    X-purgate-Ad: For more information about eXpurgate please visit 
http://www.expurgate.net/


With real PCRE, the expression would look like this:

.*\nX-purgate-ID: (.*?)\n.*

whereas $1 would contain the id. Unfortunately, the sg expansion item
does seem to work with newlines.

It is easy to remove all lines but the first:

${sg{${sg{$spam_report}{X-purgate: }{}}}{\n.*}{}}

This returns: "Spam"

But all tries to extract the id (or furthermore remove anything before
and after) in one step failed. The only way that worked was this:

${sg{${sg{${sg{$spam_report}{X-purgate: .*\n}{}}}{X-purgate-Ad:
.*}{}}}{.*X-purgate-ID: (.*)\n.*}{\$1}}

But it looks very ugly. Any ideas, how this could be done nicer?

Kind regards
Marten