Need help with Regex Filter

vprasad84 96 Reputation points
2022-01-19T07:19:45.05+00:00

Need help on a regex filter for replacing the text/string
e.g

******@support.domain.com should be replaced with support@keyman .com
******@support.domain.com should be replaced with sales@keyman .com
******@support.domain.com should be replaced with info@keyman .com

I am looking for a single regex filter to achieve. Basically this will be used as a transport rule on email server for rewriting the email address. Can someone help with exact regex filter.

Exchange | Exchange Server | Management
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ChangChun Wang 1 Reputation point
    2022-01-19T07:56:58.81+00:00

    Regex is _emp\d{3}@support.
    if you program with C#,sample code is :

    System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("_emp\d{3}@support\.", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

    string inpstr = Console.ReadLine();

    if (reg.Match(inpstr).Success)
    {
    string outstr = reg.Replace(inpstr, "@");
    }

    0 comments No comments

  2. Kael Yao 37,746 Reputation points Moderator
    2022-01-20T01:17:17.913+00:00

    Hi @vprasad84

    It is supported to use regex in mail flow rules.
    However, there isn't any option to rewrite the email address by using mail flow rules.

    The available conditions and actions are listed in this link: Mail flow rule conditions and exceptions (predicates) in Exchange Server

    To rewrite the email address, you may need an Edge transport server to use the Address rewrite feature.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.