Gmail’s documented filter criteria use Gmail search syntax, not a general wildcard or regular-expression engine. Do not expect expressions such as .*, anchors, or capture groups to behave like a programming language’s regex search. Use supported operators and explicit alternatives, then inspect actual matches.
Choose a documented alternative
- Use
from:,to:, orsubject:for a known field. - Use quotation marks for an exact phrase.
- Use OR or braces for alternatives, such as
{subject:invoice subject:receipt}. - Use a minus sign for an exclusion, such as
subject:invoice -subject:draft.
The examples illustrate search logic, not a promise that every similar-looking token is an exact field boundary. Inspect full addresses and the individual matching message, especially when conversations contain several replies.
Test positive and negative examples
- Write down which real messages should match.
- Identify similar messages that must remain unaffected.
- Run the proposed query as a search and compare both groups.
- Create only a label-only filter until new deliveries confirm the behavior.
A query that finds one wanted message can still be too broad for automation. Avoid treating a small first page as evidence that unrelated senders or subjects are excluded.
Escalate requirements that exceed mailbox search
If you need complex validation, exact domain enforcement, or a formally tested organizational policy, ask your administrator about the appropriate managed mail controls. Administrative matching features and Gmail’s personal filters have different capabilities; do not transfer syntax from one into the other without documentation.
A third-party script or extension may advertise regex processing, but it can require sensitive mailbox access and introduce a separate automation system. Do not grant that access merely to recreate a simple supported search. Prefer a maintainable set of explicit conditions, keep destructive actions out of testing, and record any limitation rather than promising that an unsupported expression will safely filter every future message.
Browse Gmail & Google Account help
References
Reviewed against the linked product guidance, standards, and identified vendor or public-authority guidance on October 29, 2026. Available options and screen labels can vary by account, device, region, and organization policy.