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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count the # of Charact...
Power Automate
Unanswered

Count the # of Characters before number

(0) ShareShare
ReportReport
Posted on by

Hello,

 

Seems to be harder than it should be but all I want to do is count the amount of characters before a number appears in the string.

 

Example

 

Joe Smith 12 West Wing, Orlando

 

Seeing as the "Joe Smith" can be any name and the numbers after for the address.. 

 

I simply want to count how many characters are before the 12.... 

 

Any one have any ideas?

Categories:
I have the same question (0)
  • ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @jderoock-w 

     

    Here is the sample flow. 

     

    In this example, I have stored the input string in a compose action:

    ManishSolanki_0-1704938006008.png

    Joe Smith 12 West Wing, Orlando

     

    Next, add another compose action to create an array of words used in the input string. You would need an expression to perform this. Expression needs to be entered in the expression box as shown below:

    ManishSolanki_1-1704938180635.png

    split(outputs('Compose'),' ')

     

    Following that, add Select action to create an array of objects as shown below:

    ManishSolanki_2-1704938332628.png

    Expression used for 'From' parameter:

    range(0,sub(length(outputs('Compose_2')),1))

    Expression used for Map key & value:

    Key Value
    index item()
    item
    outputs('Compose_2')[item()]

     

    Now, add filter array to find the index of number in an array. Pass the output of Select action to the 'From' parameter:

    ManishSolanki_3-1704938725233.png

    click "Edit in advanced mode" button on the bottom and enter the below query:

    @equals(isInt(item()?['item']), true)

     

    After that, add another filter array to get all the elements whose index is less than where number is stored. In From parameter, pass the output body of select action as shown below:

    ManishSolanki_5-1704939065188.png

    Filter query used in above screenshot:

    @less(item()?['index'], first(body('Filter_array'))?['index'])

     

    Add another Select action to create an array of words that appears before the number in the input string. In from parameter, pass the body of filter 2 action:

    ManishSolanki_6-1704939197976.png

    Click on "Switch Map to text mode" button on the right side of Map parameter:

    ManishSolanki_7-1704939291434.png

    Enter the following expression in the Map textbox:

    ManishSolanki_11-1704939811006.png
    item()?['item']

     

    To calculate the length of the required characters, we will combine the array elements and then using expression calculate its length to give the final result. Add compose action for this operation:

    ManishSolanki_9-1704939487778.png

    The output of compose gives the count of characters before the number appears in the input string.

     

    Output:

    ManishSolanki_10-1704939609643.png

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • v-jefferni Profile Picture
    on at

    Hi @jderoock-w ,

     

    I use a do until method to achieve your requirement instead:

    vjefferni_0-1704942070278.png

    vjefferni_1-1704942185052.png

    vjefferni_2-1704942208054.png

     

    so, I use isInt function to judge if next item in the array is numeric, if not then stop iterating.

    isInt(outputs('Compose_2')[variables('11')])

     

    Best regards,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard