Previous Section Next Section

$+

Match one or more tokens LHS operator

The $+ operator is very handy when you need to match at least one token in the workspace. For example, recall that the host part of an address containing zero tokens is bad, but one containing one or more tokens is good:

george@            zero tokens is bad
george@wash        one token is good
george@wash.dc.gov many tokens is good

A rule that seeks to match the host part of an address might look like this:

R $- @ $+            $: $1 < @ $2 >

Here, the LHS matches any complete address—that is, an address that contains a user part that is a single token (such as george), an @ character, and a host part that is one or more tokens (such as wash or wash.dc.gov).[15] Any address that matches is rewritten by the RHS to focus on the host part. Focusing an address means to surround the host part in angle braces. Thus, for example, george@wash will become george<@wash>.

[15] Note that this simple example will not match more complex user parts, such as george+nospam or bob.smith. Examine the sendmail.cf file to see how more complex user parts can be handled.

Note that the $+ operator can be used only on the LHS of rules, and can be referenced by a $digit operator on the RHS.

    Previous Section Next Section