The Mutt E-Mail Client : Advanced Usage : Patterns : Complex Patterns
Previous: Pattern Modifier
Next: Searching by Date

## 4.2.2. Complex Patterns

Logical AND is performed by specifying more than one criterion. For example:

> `

>     ~t mutt ~f elkins

> `

would select messages which contain the word ``mutt'' in the list of recipients and that have the word ``elkins'' in the ``From'' header field.

Mutt also recognizes the following operators to create more complex search patterns:

- ! -- logical NOT operator
- | -- logical OR operator
- () -- logical grouping operator

Here is an example illustrating a complex search pattern. This pattern will select all messages which do not contain ``mutt'' in the ``To'' or ``Cc'' field and which are from ``elkins''.

> `

>     !(~t mutt|~c mutt) ~f elkins

> `

Here is an example using white space in the regular expression (note the ' and " delimiters). For this to match, the mail's subject must match the ``ˆJunk +From +Me$'' and it must be from either ``Jim +Somebody'' or ``Ed +SomeoneElse'':

> `

>      '~s "^Junk +From +Me$" ~f ("Jim +Somebody"|"Ed +SomeoneElse")'

> `

Note that if a regular expression contains parenthesis, or a veritical bar ("|"), you must enclose the expression in double or single quotes since those characters are also used to separate different parts of Mutt's pattern language. For example,

> `

>     ~f "me@(mutt\.org|cs\.hmc\.edu)"

> `

Without the quotes, the parenthesis would truncate the regular expression to simply me@, which is probably not what you want.

The Mutt E-Mail Client : Advanced Usage : Patterns : Complex Patterns
Previous: Pattern Modifier
Next: Searching by Date