How to add a GMail filter for multiple accounts

Let’s say you want to filter messages sent to foo@example.com and bar@example.com and apply the ‘MyCompany’ label to those messages. You may think that typing the following in the ‘To’ field of the filter will work:

foo@example.com, bar@example.com

but it doesn’t. It doesn’t work with ; either.

In order to add multiple addresses to the filter you have to separate them with a | or wrap them in parentheses and use OR as the separator. The following are working examples:

foo@example.com | bar@example.com
(foo@example.com OR bar@example.com)

The same can be applied when searching email.