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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Split string by delimi...
Power Apps
Answered

Split string by delimiters - unknown length

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I have a string of text that I am trying to put into a collection in the format

*|RoleA|Auth1|Auth2|Auth3*|RoleB|Auth1|Auth8

 

I am trying to split this into columns in a collection, to then present as separate items in a gallery (grouped by Role)

 

I am able to split fine but the issue I am having is the number of auths can vary depending on the role. Is anyone able to assist with the correct syntax to split out the rows by *| and then the columns by | or would it be easier to loop through as one long list somehow? 

 

Many thanks

 

Categories:
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @nemo1 ,

     

    Please try:

    With(
     {TheString:"*|RoleA|Auth1|Auth2|Auth3*|RoleB|Auth1|Auth8"},
     ForAll(
     LastN(Split(TheString,"*|"),CountRows(Split(TheString,"*|"))-1),
     {
     Role:First(Split(Value,"|")).Value,
     Auth:LastN(Split(Value,"|"),CountRows(Split(Value,"|"))-1)
     }
     )
    )

    vbofengmsft_0-1714612646083.png

     

    Best Regards,

    Bof

     

  • nemo1 Profile Picture
    on at

    thanks. How do I add the syntax to put this into a collection please? Can't work out where if fits into the for all statement

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @nemo1 ,

     

    You could try:

    ClearCollect(CollectionName,
    With(
     {TheString:"*|RoleA|Auth1|Auth2|Auth3*|RoleB|Auth1|Auth8"},
     ForAll(
     LastN(Split(TheString,"*|"),CountRows(Split(TheString,"*|"))-1),
     {
     Role:First(Split(Value,"|")).Value,
     Auth:LastN(Split(Value,"|"),CountRows(Split(Value,"|"))-1)
     }
     )
    )
    )

     

    Best Regards,

    Bof

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard