Summary
The RegEx Service allows executing regular expressions in Power Automate or other cloud-based automation tools that do not have support for regular expressions. This article shows how to configure the server and client sides, and how to use it.

Details
This example uses a flow in TeamDynamix iPaaS to expose a service to process a regular expression and text. It receives the regex and text via HTTP, processes the regex in JavaScript, and returns the results in JSON format.
In the Power Automate side, the example shows how to call this RegEx Service using the HTTP connector.
Setting Up RegEx Service in iPaaS
Note: U-M users can skip this step. Simply email the Mobile Technologies Core to get the URL.
- Login to iPaaS and create (or open) an application (e.g. EFDC-Sandbox)
- On the left panel, click Flows
- On the upper right, click the green Add button and select Add from Import

- Paste the contents of RegExService.json and click Import

- Once the flow is imported, click on it to open it

- On the left panel, navigate to Flows -> RegEx Service -> API Management -> API Endpoints. Copy the URL to the latest version (or the short URL if enabled)

- Under Endpoint Security, ensure you give open access to everyone
Importing Sample Client Flow into PowerAutomate
- Download RegExClient.zip
- Login to Power Automate
- On the left panel, click My Flows
- On the top bar, click Import -> Import Package (Legacy)
- Follow the steps to import RegExClient.zip
- If the import fails, try creating the flow manually with three actions:
- Compose: Enter the input parameters in JSON format
- HTTP: Paste the RegEx Service URL into the URI field, change the method to POST, add a parameter
WaitForResults=true, and put the results of the previous compose into the Body
- Parse JSON: Enter the Body of the previous HTTP action in Content, and click "Use sample payload to generate schema". Use this as the sample:
{"data":{"ResultValue":[""],"ResultCode":200}}
- Open the flow again, and edit the HTTP action. Paste the RegEx Service URL into the URI field
- Save the flow and click Test to test it

Using the RegEx Service
- U-M users can obtain the URL for the RegEx Service by emailing the Mobile Technologies Core team at: efdc-mobiletech@umich.edu
- The URL must have this parameter at the end: WaitForResponse=true
- The text and regular expression are sent in the body of the HTTP request in this format:
{
"Text": "This is a famous test",
"Pattern": "famous+.*",
"Flags": "gim",
"Method": "match",
"Replacement": ""
}
- Valid values for Method are: match, replace, replaceAll, search, split. These are standard JavaScript text regular expression functions.
- The input text can be no more than 20,000 characters, and the pattern (regex) must be no longer than 200 characters.
- The response will return an HTTP status code of 200 if successful, 400 if the input has an error, or 500 if there is an unknown error.
- The response looks like the following:
{
"customerId":9999,
"flowOccurrenceId":999999999,
"flowOccurrencePId":"28372dec-47ae-4969-80cf-1bea24c9a5ae",
"data": {
"ResultValue": ["famous test"],
"ResultCode": 200
}
}
Notes
- This example uses iPaaS to create the RegEx Service. However, the JavaScript code in it can be used by any node-compatible server.
Resources
About the Author
 |
Gabriel Mongefranco is a Mobile Data Architect at the University of Michigan's Eisenberg Family Depression Center. Gabriel has over a decade of experience with automation, data analytics, database architecture, dashboard design, software development, and technical writing. He supports U-M researchers with data cleaning, data pipelines, automation and enterprise architecture for wearables and other mobile technologies.
| | |
|