Word matching in Exchange Transport Rules

HCHTech

Well-Known Member
Reaction score
4,252
Location
Pittsburgh, PA - USA
This is kind of a long-standing question for me, and some work today brought it back to the fore.

When you are creating an Exchange Transport Rule, and you want to enter an exception if the body of the email contains a specific phrase, do you use the operator "Subject or body includes any of these words" or "Subject or body matches these text patterns"?

I think MS has changed the wording of these selections over the years, and on its face, it appears that if you want the exception ONLY if a specific phrase is found, then you shouldn't be using the "Subject or body include any of these words". If you then enter the phrase "Elephant Graveyard", that would imply that the exception would fire if either the word "Elephant" or the word "Graveyard" was found.

Conversely, the other choice "Subject or body matches these text patterns" seems like the right choice for an exact phrase match. However, it isn't clear to me whether you have to put your answer in regex for this choice. I know regex expressions are ALLOWED, but I don't know if they are REQUIRED. For my example, can I just type in "Elephant Graveyard", or must I type \bElephant Graveyard\b (or some other regex equivalent)?

I've tried some trial and error, but it would be nice to know the real answer. Does anyone know?

Extra credit question: Why does it take SO LONG to save a new rule (over 40 seconds!)? THEN, the rule is created DISABLED, so you have to ENABLE it as a separate step, which takes ANOTHER 40 seconds. So frustrating.
 
"Subject or body includes any of these words" matches text as written.
"Subject or body matches these text patterns" is RegEx.

I avoid regex like the plague! But it's absurdly powerful for those that can delve into its arcane ways.

Documentation is key: https://learn.microsoft.com/en-us/e...nce/mail-flow-rules/conditions-and-exceptions

Note the above documentation link was quickly located via CoPilot query, because while I knew this... I didn't know where the documentation was. Copilot, knows these things!
 
"Subject or body matches these text patterns" is RegEx.

Yes, I think I agree with you, as the documentation section on that is clear - I think:

The subject or body matches
The subject or body > subject or body matches these text patterns
SubjectOrBodyMatchesPatterns
ExceptIfSubjectOrBodyMatchesPatterns
PatternsMessages where the Subject field or message body contains text patterns that match the specified regular expressions.

"...text pattern that match the specified regular expressions"...Implying the match entry MUST BE regex. Fun fact, MS has it's own set of regex expressions that work, you can't just use any regex expression that exists in the wider world.

"Subject or body includes any of these words" matches text as written.


Yes, I have looked at that documentation. You might be right, but you have to agree, though, that the title "includes ANY of these words" does certainly not imply "includes ALL of these words in the order written". The documentation section is just not clear, IMO:

The subject or body includes
The subject or body > subject or body includes any of these words
SubjectOrBodyContainsWords
ExceptIfSubjectOrBodyContainsWords
WordsMessages that have the specified words in the Subject field or message body.

Why would they use the word ANY to mean the word ALL? If fact, ANY implies just ONE of the entry of multiple words would fire the notification. This is why I posted my question. It could very well be that this is just a mistake/unintentional-obfuscation on the documentation writer's part, but I don't know. That's what I was hoping to clarify.
 
Ahh, yes. I see what you're going after.

"All of these words" matches the entire phrase, "all" "of" "these" "words", matches each individually.
 
Maybe, but that's not what the documentation says. I'm happy if you're right, but that means the documentation is wrong or at best, incomplete & misleading. IMO
It's written by copilot, so yeah... misleading is the name of the game. It's usually not incomplete though.
 
MS has it's own set of regex expressions that work, you can't just use any regex expression that exists in the wider world.

Indeed, which is maddening. I don't use them often in Windows world as a result. Everyone else uses one of the several *nix styles, which are not all that different from each other for most common pattern matching.

I've been using regular expressions for decades now when needed. Remember that a text string is a regular expression that matches itself. The power comes in with the use of the other aspects of regex.
 
@HCHTech

There are far too many use cases for me to possibly offer, but what I'll do is offer a collection of links that I once snagged that give a range of those use cases along with the various regular expressions that cover them. I am not responsible for the link names and have not used all of these regexes for their intended purposes.

Match elements of a url
Validate an ip address
Match an email address
Match or Validate phone number
Match dates (M/D/YY, M/D/YYY, MM/DD/YY, MM/DD/YYYY)
Match html tag
Empty String
Checks the length of number and not starts with 0
Not Allowing Special Characters
Match a valid hostname
Validate datetime
string between quotes + nested quotes
Match IPv6 Address
Match brackets
match a wide range of international phone number
Url
email validation
Match an MD5 hash

These days, this is my most common use case for regular expressions: Using the NVDA Dictionaries with Regular Expression Matching to Change Pronunciations (docx)
 
Back
Top