How to extract numbers from string in Power Automate

Hello everyone and welcome to my blog. Today we will walkthrough how you can extract numbers from a string using Power Automate flows.

Through my blog I share interesting tips and discuss on latest releases of Microsoft.NET technologies, Dynamics 365 and Power Platform, SharePoint and Client scripting libraries. Please subscribe to my blog to stay updated.

Let’s take a look at the requirement. For this blog I will use this sample string – ABCDE472934fjlsfl.

The string contains characters as well as numbers. My requirement is to extract numbers from the string. The final expected output is 472934. Let’s see how we can do this.

The first step is to convert the string into an array of characters. Follow the steps mentioned in this blog to convert the string into an array of characters.

We will start this blog assuming you were able to convert the example string above into an array of characters.

I create an instant flow and start directly with the array variable. Below is the illustration of array variable – varArray.

Also notice that I have declared another variable varNumberArray. This array shall be used to store the numbers only.

The next step is to iterate through the array. The following operations are completed in the illustration below.

  • Check if the current item in an integer. I am using out-of-box isInt function for this purpose.
  • If the current item is integer, I am appending that item to the varNumberArray variable.

So now I have only integer values in the array. The final step is to join the items in the array to get the desired output.

I use the Compose step of the Data Operation action for the same.

All steps completed. Now when I run the flow, I get the desired output. Illustration below.

Debajit Dutta
Business Solutions MVP