This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
reference:spamrules_statement_ifmatch [2011/08/22 13:38] – simon | reference:spamrules_statement_ifmatch [2018/11/14 10:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
**IfMatch** statements require a data parameter and a search value, in the format | **IfMatch** statements require a data parameter and a search value, in the format | ||
IfMatch < | IfMatch < | ||
+ | |||
+ | The **IfMatch** statement must be terminated with an **EndIf** and may contain an **Else** statement, just like the [[spamrules_statement_if|If]] statement. | ||
=====Data===== | =====Data===== | ||
Line 30: | Line 32: | ||
^whitelist | ^whitelist | ||
^blacklist | ^blacklist | ||
- | ^''< | + | ^''< |
- | ^Raw-''< | + | ^Raw-''< |
^attachment | ^attachment | ||
^rawmessage | ^rawmessage | ||
Line 37: | Line 39: | ||
=====Search===== | =====Search===== | ||
- | The search parameter to the **IfMatch** statement can either be a regular expression or a simple substring search string. | + | The search parameter to the **IfMatch** statement can either be a regular expression or a simple |
You should put quotes around the text or Perl Compatible Regular Expression (PCRE) to search for. | You should put quotes around the text or Perl Compatible Regular Expression (PCRE) to search for. | ||
Line 53: | Line 55: | ||
^D |The dollar character matches only at the end of the search string. Without this, it can also match immediately before the final character if it is a newline character. | | ^D |The dollar character matches only at the end of the search string. Without this, it can also match immediately before the final character if it is a newline character. | | ||
^U |The search will be “ungreedy” instead of the default mode of greedy. | | ^U |The search will be “ungreedy” instead of the default mode of greedy. | | ||
- | |||
- | The **IfMatch** statement must be terminated with an **EndIf** and may contain an **Else** statement, just like the [[spamrules_statement_if|If]] statement. | ||
=====Example===== | =====Example===== | ||
- | This following example will perform a regular expression search of the Subject line of the message header to see if it contains the text **hello** anywhere. | + | This following example will perform a case insensitive |
< | < | ||
IfMatch subject "/ | IfMatch subject "/ | ||
+ | # Statements | ||
+ | EndIf | ||
+ | </ | ||
+ | |||
+ | The example above does not need a regular expression and could also be achieved with a substring search, like so: | ||
+ | < | ||
+ | IfMatch subject " | ||
+ | # Statements | ||
+ | EndIf | ||
+ | </ | ||
+ | |||
+ | This following example uses a regular expression to check whether a Cc header is present | ||
+ | < | ||
+ | IfMatch cc "/ | ||
# Statements | # Statements | ||
EndIf | EndIf | ||
</ | </ |