Microsoft Security Tech Accelerator
Dec 06 2023, 07:00 AM - 12:00 PM (PST)
Microsoft Tech Community

Examples of "subject matches patterns" regular expression when auto-applying sensitivity label

Copper Contributor



I'm trying to auto-apply a sensitivity label to Exchange content (a specific user mailbox) where the rule is defined by a "subject matches patterns" condition. Microsoft requires a regular expression here. The emails I'm trying to apply the label to all have the words "Litigation Hold" in the subject line. I've tried to capture these using the following regular expressions but none have worked: (?:Litigation Hold), \bLitigation Hold\b, \sLitigation Hold\s, ^(?:Litigation Hold)$, Litigation Hold. What syntax is Microsoft looking for here? Any help or examples would be appreciated, thank you.

3 Replies
best response confirmed by tgraham-legalops (Copper Contributor)



I'm sorry it took so long for you to get a response here but I believe, after some testing, that this is the regex you'd want to use, which will establish the word boundary as you were already trying to do, but you still need to use the "?:" to set the non-capture sub-pattern.


\b(?:Litigation Hold)\b


If you go to regex101: build, test, and debug regex and choose .NET (C#) as the flavor and get a match, then it will match within Microsoft.










@miller34mike Thank you! Have you had any luck using the "Header matches patterns" condition? No matter what I try, I can't get that one to work. Any tips would be greatly appreciated. 



Unfortunately, I have not used or tested that condition in the past. If you'd like to send me a specific example through a direct message on here I'll happily circulate it with others to see if we can find the resolution.