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 : xNeCTuR+ZhF8ABXmc7RpZ0
Power Apps - Building Power Apps
Answered

Replacing a string with mutiple commas by a single comma using Regex

Like (0) ShareShare
ReportReport
Posted on 19 Nov 2019 01:21:32 by 169

i have a large string that is a result of a http call. This string is '@' separated, but within each item in the string i have multiple occurrences of commas that i will like replaced by just a simple comma.
An example of the string is  "Flat 1, Society Court,,,Aberdeen,Scotland@Flat 2, Society Court,,,Aberdeen,Scotland"
Basically i want this String to be in this format "Flat 1, Society Court,Aberdeen,Scotland@Flat 2, Society Court,Aberdeen,Scotland"

After which i can then split the text and store the results in a collection. This is what i have so far
ClearCollect(col_addresses, Split(Substitute(var_text,Match(var_text,"[,]{2,}").FullMatch,","),"@") )

 

What i have tried to do is find any matches in the string where there are multiple commas, and then replace them with a single comma, i then split the result. When i check the collection i just get the split on the original string with the commas still as they were.

 

it seems the Match function may not do the job or am i doing something wrong. Any ideas?

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,987 Moderator on 19 Nov 2019 at 01:43:14
    Re: Replacing a string with mutiple commas by a single comma using Regex

    @Gottijay2000 

    You can put this string in a Text Input called TextInput1

     

    Flat 1, Society Court,,,Aberdeen,Scotland@Flat 2, Society Court,,,Aberdeen,Scotland

     

    Then put this code in another text label

     

    Left(
     Concat(Filter(Split(TextInput1.Text,","),!IsBlank(Result)),Result&","),
     Len(Concat(Filter(Split(TextInput1.Text,","),!IsBlank(Result)),Result&","))-1
    )

     

    Your result will look like this.

     

    Flat 1,Society Court,Aberdeen,Scotland@Flat 2,Society Court,Aberdeen,Scotland

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 982 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 396 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 356

Last 30 days Overall leaderboard