How to Use Wildcards and Regular Expressions in Exchange Online Transport Rules
Question details
The user needs to configure an Exchange Online mail flow rule to match specific subject formats, such as 'Invoice123456', but wildcard patterns are not working.
- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- Setting up a mail flow rule for a shared mailbox to properly filter or route messages based on specific strings in the subject line.
- Observed behavior
- Using the wildcard pattern 'Invoice.*' does not trigger the rule as expected because the system interprets the wildcard characters literally rather than dynamically.
Ensure you have Exchange Admin Center privileges to manage mail flow rules, and be aware that newly created or modified transport rules can take up to 30 minutes to fully propagate.
Use Simple Keywords Instead of Literal Wildcards
Use specific keywords when you need to match a string containing a certain word, as wildcard characters like .* are often treated as literal text in basic conditions.
In many Exchange transport rule fields, regular expression syntax like .* is not recognized and is interpreted literally. This means the rule looks for the exact string 'Invoice.*' instead of 'Invoice' followed by any characters.
Log in to the Exchange Admin Center and navigate to the Mail flow > Rules section.
Select and edit your mail flow rule. Locate the condition for 'The subject or body includes'.
Instead of typing 'Invoice.*', enter the exact keyword 'Invoice'. This will successfully match any subject line containing the word 'Invoice'.
Apply Text-Pattern Conditions for Regular Expressions
Use specific text-pattern conditions that explicitly support regular expressions for more precise and complex subject matching.
Handle Multiple Conditions with Separate Rules (OR Logic)
Create individual rules for multiple patterns because adding multiple conditions to a single rule applies AND logic, not OR logic.
Enhance Your Daily Productivity with WPS Office
While troubleshooting complex Exchange Online mail flow rules, you might also be looking for a robust, lightweight, and cost-effective productivity suite for your everyday tasks. WPS Office is a powerful free alternative to Microsoft Office that ensures seamless migration and high efficiency.
- 1. Visit the Official Website: Go to the official WPS Office website to explore the features.
- 2. Download the Installer: Click the 'Free Download' button to download the appropriate installer for your Windows, Mac, or Linux operating system.
- 3. Install the Software: Run the downloaded file and follow the straightforward on-screen instructions to complete the installation.

Frequently Asked Questions
Why aren't my multiple transport rule conditions triggering as an OR statement?
Exchange transport rules inherently use AND logic when multiple conditions are added within the same rule. To achieve an OR-like result where any one of multiple patterns triggers an action, you must create separate transport rules for each pattern.
How long does it take for a new Exchange transport rule to apply?
It can take up to 30 minutes for new or modified Exchange transport rules to fully propagate and start processing inbound or outbound emails across all servers.
How can I verify if my transport rule regular expressions are working correctly?
You can use the Message Trace feature located in the Exchange Admin Center to track incoming emails, test your configuration, and verify exactly which transport rules were triggered during processing.




