Message.getRegExMatches method (JavaScript API for Office v1.0)

apps for Office

Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file.

Last modified: February 26, 2015

var matches = Office.context.mailbox.item.getRegExMatches();

An array that contains the strings that match the regular expressions defined in the manifest XML file.

The getRegExMatches method returns the strings that match the regular expression defined in each ItemHasRegularExpressionMatch or ItemHasKnownEntity rule element in the manifest XML file. For an ItemHasRegularExpressionMatch rule, a matching string has to occur in the property of the item that is specified by that rule. The PropertyName simple type defines the supported properties.

If you specify an ItemHasRegularExpressionMatch rule on the body property of an item, the regular expression should further filter the body and should not attempt to return the entire body of the item. Using a regular expression such as .* to obtain the entire body of an item does not always return the expected results.

The following example shows how to access the array of matches for the regular expression regex1, which is specified in the manifest. Note that the current item in Microsoft Outlook can be a Message object or an Appointment object, both of which are derived from the Item object.

// The initialize function is required for all apps.
Office.initialize = function ([leave "reason' if it's already there]) {
    // Checks for the DOM to load using the jQuery ready function.
    $(document).ready(function () {
    // After the DOM is loaded, app-specific code can run.
   // Get an array of string matches from the regular expression regex1, as specified in the manifest.
    var matches = Office.context.mailbox.item.getRegExMatches().regex1;
    // Continue processing the matches for the regular expression.

Supported clients

Outlook 2013, Outlook 2013 SP1, Outlook 2013 RT, Outlook Web App, OWA for Devices, Outlook for Mac


Outlook-15.js, OutlookWebApp-15.js



© 2015 Microsoft