Insert text using a regular expression
The RegexMatch macro in Shared Email Templates automatically scans an Outlook email for a regular expression (regex) match and, depending on whether a match is found or not, inserts one of the two specified pieces of text. To add the macro to your template, follow the steps below.
Start creating or editing a template.
Place the cursor where you want to insert the predefined text.
On the template editor toolbar, select the
Insert macro button.Select RegexMatch.
In the Regex match dialog:
- Select the fields you want to search for a regex match (message body, From, To, Cc, Bcc, Subject, recipient’s first, last, or full name, sender’s first, last, or full name).
- Enter a regex.
- If you want to make the search case insensitive, select the corresponding checkbox.
- Enter the value if matched (the text that will appear in your email message if a regex match is found).
- Enter the value if not matched (the text that will appear in your email message if a regex match is not found).
When you’re ready, select OK.

Save the template.
When you insert the template into an Outlook email message, the fields you selected are searched for a regular expression match. If a match is found, the first piece of text is inserted; if not, the second one is used instead.
