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 / How i can split a stin...
Power Automate
Suggested Answer

How i can split a sting to generate Array without empty string

(0) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1
I have a Child Flow which accept names in a semi-collon separate string, here are examples of the string:-
 
;test
 
test;test2
 
test;;test2
 
test
 
 
now i want to generate an array but i do not want the array to have empty strings .. can i write a single formula to do this? i do not want to do a separate action to filter the Array. i am searching to do this in a single formula..Thanks
Categories:
I have the same question (0)
  • lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at
    Are these all the possible examples? :-)
     
    split(
      if(
        startswith(replace(outputs('String'),';;',';'),';'),
        substring(replace(outputs('String'),';;',';'),1),
        if(endswith(replace(outputs('String'),';;',';'),';'),
          substring(replace(outputs('String'),';;',';'),0,length(replace(outputs('String'),';;',';'))-1),
                replace(outputs('String'),';;',';')
        )
        )
    ,';')
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    Thanks for the formula, but i got that it is not valid when i add it to the compose action. any advice? As i know that SubString() should contain 3 parameters, but your first SubString() contains only 2 parameters

    for the combination, i might have this string format:-

    ;p;;p6;

    where i only need p & p6..
    Thanks
  • Suggested answer
    Ellis Karim Profile Picture
    11,691 Super User 2025 Season 2 on at
     
    Would this expression work for you? I've updated the expression based on your sample data.

     

     
    json(replace(replace(string(split(variables('varString'),';')),'"",',''), '""]',']'))
     

     
    Ellis
     
  • lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at
    The third parameter of substring is optional if you want to get the whole rest of the string.

    I forgot that you cannot subtract numbers easily in Power Automate.

    split(
      substring(replace(variables('String'),';;',';'),
        if(startswith(replace(variables('String'),';;',';'),';'),1,0),
        sub(length(replace(variables('String'),';;',';')),
          add(if(startswith(replace(variables('String'),';;',';'),';'),1,0),
              if(endswith(replace(variables('String'),';;',';'),';'),1,0)
          )
        )
      ) 
    ,';')


  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    Thanks , but i am getting invalid error when i tried to add your formula
  • lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at
    I updated my response.

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard