On Mon, 3 May 2021 10:18:51 -0500 (CDT)
Dave Funk wrote:

> I'm trying to create a rule to count the number of instances of a
> particular header.
...
> What am I doing wrong? How should I craft a rule to count the number
> of instances of that header?

It's important to understand that when headers are repeated, the match
runs against a single string with multiple lines, not multiple strings. 

So

  header L_MY_HEADER  X-My-Header =~ /^.{5,200}/

can only match once because, by default, ^ matches the beginning of
the string. 

For header tests involving multiple lines, the /m and /s modifiers
can be useful, but are often not essential as you can test for newline
characters instead. 

You only need tflags multiple if you need to get a numerical 
value for meta-rules, you can write a rule for N or more headers using
a single header rule.

e.g. to test for two or more headers (if empty headers aren't a
concern) you can simply use:

header L_MULTIPLE_MY_HEADER X-My-Header =~ /\n./

Reply via email to