General-Purpose Mail Filter
The ‘#pragma regex’, controls compilation of expressions. You can use any number of such pragma directives in your mailfromd.mf. The scope of ‘#pragma regex’ extends to the next occurrence of this directive or to the end of the script file, whichever occurs first.
The optional push|pop parameter is one of the words ‘push’ or ‘pop’ and is discussed in detail below. The flags parameter is a whitespace-separated list of regex flags. Each regex-flag is a word specifying some regex feature. It can be preceded by ‘+’ to enable this feature (this is the default), by ‘-’ to disable it or by ‘=’ to reset regex flags to its value. Valid regex-flags are:
Use POSIX Extended Regular Expression syntax when interpreting regex. If not set, POSIX Basic Regular Expression syntax is used.
Do not differentiate case. Subsequent regex searches will be case insensitive.
Match-any-character operators don’t match a newline.
A non-matching list (‘[^...]’) not containing a newline does not match a newline.
Match-beginning-of-line operator (‘^’) matches the empty string immediately after a newline.
Match-end-of-line operator (‘$’) matches the empty string immediately before a newline.
For example, the following pragma enables POSIX extended, case insensitive matching (a good thing to start your mailfromd.mf with):
#pragma regex +extended +icase
Optional modifiers ‘push’ and ‘pop’ can be used to maintain a stack of regex flags. The statement
#pragma regex push [flags]
saves current regex flags on stack and then optionally modifies them as requested by flags.
#pragma regex pop [flags]
does the opposite: restores the current regex flags from the top of stack and applies flags to it.
This statement is useful in module and include files to avoid disturbing user regex settings. E.g.:
#pragma regex push +extended +icase . . . #pragma regex pop
This document was generated on January 3, 2019 using makeinfo.Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.