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 / Divide text string int...
Power Apps
Answered

Divide text string into several pieces based on a date

(0) ShareShare
ReportReport
Posted on by 181
Hi,
 
I have a long text string with comments that is built like this:
 
"2024-10-01
Blablablabla

2024-10-02
Blabla bla bla
 
etc."

Now I want to divide this string into pieces where the new strings start with the dates each time. The idea is to use Split and MatchAll, but I can't figure out how to combine these functions. Or is there any better ideas?

All ideas are welcome and appreciated!
Categories:
  • Verified answer
    ronaldwalcott Profile Picture
    3,914 Moderator on at
    Something like this should work even though needs to be optimized. The example is created with a label and a button.
     
    Label1.Text set to 
    "2024-10-01 Blablablabla 2024-10-02 Blabla bla bla 2024-10-03 TestBlabla bla bla"
    "\d\d\d\d\-\d\d\-\d\d" is a regular expression representing the format of the date in your example
     
    The button OnSelect set to 
     
    UpdateContext({theStringLength: Len(Label1.Text)});
    
    ClearCollect(
        myIndexedTable,
        With(
            {
                data: ShowColumns( MatchAll(Label1.Text, "\d\d\d\d\-\d\d\-\d\d"),StartMatch)
                
            },
            AddColumns(
                RenameColumns(
                    Sequence(CountRows(data)),
                    Value,
                    Index
                ),
                StartString,
                Index(
                    data,
                    Index
                ).StartMatch
            )
        )
    );
    
    ClearCollect(mySearchTable, myIndexedTable);
    
    ClearCollect(
       myStringStartAndSize,
       AddColumns(
          myIndexedTable,
          strLength,
          With({
          getStringPosition:LookUp(mySearchTable,  Index = myIndexedTable[@Index] + 1, StartString)
          },
          If ( !IsBlank( getStringPosition)  , getStringPosition -  myIndexedTable[@StartString], theStringLength - myIndexedTable[@StartString] + 1 )
          )
       )
    ); 
    
     

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 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard