regexoffice365exchange-serverexchange-server-2010

Ms Exchange Online | Regex in Transport Rule


I want to create a Regex Transport rule for the email with Subject 1365 1049126 9003175245 19382_ST03

I want to check if the subject contains 900 in the third group of characters and the numbers after 900 are dynamic and is a single word.

For example: Subject 1 - 1365 1049126 9003175245 19382_ST03

Subject 2 - 2455 3245626 9003175000 19382_ST03

Subject 3 - 4567 4449126 9003005030 19382_ST03

How do I set this in regular expression? Any help will be appreciated.


Solution

  • You could use something like this: ^[0-9]{4}\s[0-9]{7}\s900[0-9]{7}\s\w{10}$
    ^ Matches start of strings
    [0-9]{4}\s Matches 4 digits and whitespace after them
    [0-9]{7}\s Does the same but for 7 digits
    900[0-9]{7}\s <-- This matches 900 and 7 digits and whitespace
    \w{10}s Matches 10 word characters
    $ Matches end of string
    If these groups are not ONLY digits, you can replace [0-9] with \w