web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

find the integer from the string.

(0) ShareShare
ReportReport
Posted on by 14
Hlo Everyone just a quick question:
 
Hello, I am 10 year old having 2$ and contain20 oranges with 10.222 per orange
 
From this string I want to extract integers in and provide on array [10,2,20,10.222]
 
using power automate.
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    51,278 Super User 2025 Season 2 on at
    find the integer from the string.
    Hi :-)
     
    First I am moving this to the proper location.,
  • Suggested answer
    Michael E. Gernaey Profile Picture
    51,278 Super User 2025 Season 2 on at
    find the integer from the string.
     
    To answer need a little clarity on how that "string" got into Power Automate.
     
    The answer is however that its an array already, so use Split.
     
    So if that value was in a variable called Foo.
     
    add a Compose
     
    put split(variable('Foo'), ',') and now you have an array of the values.
     

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey
  • Suggested answer
    Tomac Profile Picture
    2,768 Moderator on at
    find the integer from the string.
     
    This method is slow because it uses two nested Apply To Each loops, but because your numbers are not all nicely broken up by spaces we need to evaluate each "word" and then each character in each "word". Note that you need to set Concurrency Control for each loop to 0.
     
    Here's an overview of the flow:
     
    First, we start with variable declarations:
    The only one that needs explanation is strBlank, which is a blank string used to reset strTemp inside of the first loop.
     
    Next we move into the first loop:
    The expression that the loops runs from breaks the original string at the space characters to get each "word" as an array item:
    split(variables('strInputString'),' ')
     
    Next we have the Select action which breaks up the current "word" into an array of individual characters by value and index, and reset strTemp:
    Select From:
    range(0, length(chunk(items('Apply_to_each'),1)))
    Select Map:
    {
      "Value": @{chunk(items('Apply_to_each'),1)?[item()]},
      "Position": @{item()}
    }
     
    Then we have the second nested loop with only one action in it. This loops through each character, checks if it's a number or a period, and if so it appends it to strTemp. The loop runs on the output of the Select action. After the second loop, we use an Append To Array action that checks if the value of strTemp is greater than 0 and if it is (and is not just a period), add it to our results array. If not, add a blank value.
    Expression in the Append To String action:
    if(isint(items('Apply_to_each_2')['Value']),items('Apply_to_each_2')['Value'],if(equals(items('Apply_to_each_2')['Value'],'.'),'.',''))
    Expression in the Append To Array action:
    if(equals(variables('strTemp'),'.'),'',if(greater(length(variables('strTemp')),0),float(variables('strTemp')),''))
     
    Then we use a Filter Array action to remove the blanks:
    Left side: 
    item()
    Leave the right side blank
     
     
    Finally, we get the desired result:
     
    This isn't fast (it takes about 17 seconds to run) but it does accomplish your goal.
  • Chriddle Profile Picture
    8,313 Super User 2025 Season 2 on at
    find the integer from the string.
    The only difference is that you not only check if it is an integer (isInt()), but also if the character is a dot.
  • Tomac Profile Picture
    2,768 Moderator on at
    find the integer from the string.
    @Chriddle I knew you'd be able to simplify this process. Is there a place you learned this level of array manipulation, or a guide you can recommend to get better at it?
  • Chriddle Profile Picture
    8,313 Super User 2025 Season 2 on at
    find the integer from the string.
    It's simply a matter of practice and having the mindset to avoid loops and variables at all costs.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

Last 30 days Overall leaderboard