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 : JcZrMRLXNIxaOVG3X6f/wa
Power Automate - Building Flows
Unanswered

Extract Multiple occurances of text between characters in a String

Like (0) ShareShare
ReportReport
Posted on 11 May 2020 14:51:49 by 16

Hi,

 

I have a string that looks like this:

"Hello [contact.first], Blah Blah Blah [contact.dob] blah blah blah [contact.phone] bah blah."

 

If I wanted to grab every occurrence of [ ] and essentially loop through each, whats the best way to do it? There will always be one [ ] but they might be different and be different order etc.

 

I know I can get the contents between one occurrence but not sure how to get to each one.

 

Many thanks.

I have the same question (0)
  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on 12 May 2020 at 02:58:26
    Re: Extract Multiple occurances of text between characters in a String

    @stuax 

    Hey there -  So this isn't the prettiest, but it's what I got:

     

    What I did was replace all of the open brackets with something else like "[**" (you'll see why later).

    Then I replaced all of the close brackets with open brackets.

    Then, I did a split() on the open bracket.  This created an array with a bunch of junk, but the things I want to keep all start with "**".

     

    [
      "Hello ",
      "**contact.first",
      ", Blah Blah Blah ",
      "**contact.dob",
      " blah blah blah ",
      "**contact.phone",
      " bah blah"
    ]
     
    Here's the expression I used (replace the bold bit with your actual data):
     
    split(replace(replace(outputs('Compose'),'[','[**'),']','['),'[')
     
    To filter out the ** stuff, add a step "Filter Array", put the output from that expression as the Array, and then for the value, just put "item()" and change the operator to "Starts with" and then "**" (all without quotes) like this:
     
    20200511.PNG

     

    That output should be:
    [
      "**contact.first",
      "**contact.dob",
      "**contact.phone"
    ]
     
    And so then you can just do a Replace() to change the ** to nothing ('').
     
     
    If stuff is never in the same order, I'm not certain how you'll assign those values to actual fields, but I presume you've already worked that out.  
     
     
    Keep us posted.
    -Ed
     

    If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

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…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 786 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 724 Super User 2025 Season 2

#3
stampcoin Profile Picture

stampcoin 290 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete