Using regular expression match to extract values from text in Power Automate

In this article, we will be talking about using the Regular Expression Match action from the Plumsail Documents connector for Power Automate (Microsoft Flow) and Azure Logic Apps.

Let’s suppose you are getting a new email after someone made a purchase and you need to extract information from this email and create a new item in your SharePoint orders list.

Your email might look like this:

*** Order information ***
Time zone: GMT+00:00
Reference: 4563452
Order number: 1400
Payment method: Visa/MasterCard
Order status: Credit card payment authorized

*** Ordered products ***
Product code: D3F13B23B0
Title: Tires
Price: 150
Quantity: 4

Product code: FD3423DE
Title: Cookies
Price: 30
Quantity: 20

Product code: KFG45GK445
Title: Tools
Price: 50
Quantity: 10

*** Delivery information ***
First name: John
Last name: Doe
Company: Happy Company Ltd
Country: Australia
Phone: 01 2345 6780

To achieve this we will be using the Regular Expression Match action.

So your flow might look like this:


A step-by-step explanation is below.

When a new email arrives in Microsoft Outlook

We’re using the trigger When a new email arrives in Microsoft Outlook. If you use another email client, choose another trigger.

Then we want to work the flow only for order emails. That’s why we’re setting the subject filter with the word ‘Order’.


Regular Expression Match

Then we are using the Regular Expression Match action to find three values: Title, Price, and Quantity in our email’s body.

add regular expression match action

If this is your first time using the Plumsail Documents connector, Power Automate will request the Connection Name and API Key.

Create connection in Power Automate flow

You can type any name for the connection, for example Plumsail Documents.

Once the connection name is filled out, create an API key in your Plumsail Account, copy and paste it into the Access Key field, and then click Create.

Copying an API key from the account

The Regular Expression Match action has two fields:


  1. Pattern. Here is the patter we used to find titles, prices, and quantity:

Title: (?<Title>.+|)
Price: (?<Price>.+|)
Quantity: (?<Quantity>\d+)
  1. Text. We selected the output from the trigger to scan the email body text.

You may notice that Regular expression match in this regular expression has a few outputs:


There is “Match0” is a full match for the whole regular expression. There are also separate output values for each named regular expression group: Price, Quantity, Title.

You can learn more about named groups on this page. The action is smart enough to create separate output value in Power Automate (Microsoft Flow) for each named regular expression group that is used in it. It dramatically simplifies extraction of values from text strings. You just write a regular expression with named groups and then use them across your flow.

You can easily put match regex into a named group like this: (?<Title>.+|). The name of this group will be “Title”, everything that matches regular expression .+| will be returned as a separate output of the action.

Note, the action returns array of matches, because you may have multiple matches in your text. This is how JSON representation of result may look with multiple matches:

        "Match0": " Title: Tires\r\nPrice: 200\r\nQuantity: 4",
        "Title": "Tires",
        "Price": "150",
        "Quantity": "4"
    }, {
        "Match0": " Title: Cookies\r\nPrice: 30\r\nQuantity: 20",
        "Title": "Cookies",
        "Price": "30",
        "Quantity": "20"
    }, {
        "Match0": " Title: Tools\r\nPrice: 50\r\nQuantity: 10",
        "Title": "Tools",
        "Price": "50",
        "Quantity": "10"

Create item in SharePoint list

In the last step, we are using the values from the previous step to create an item in ‘Orders’ SharePoint list.


In this action, we are going through the ‘Matches’ array and getting its values in the cycle, using the named groups as keys. Then we use these keys values to create an item in our SharePoint ‘Orders’ list.


Now you should have an idea how to work with the Regular Expression Match action from the Plumsail Documents connector for Power Automate (Microsoft Flow). If you haven’t used it yet, registering an account would be the first step. It is quite easy to get started.