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 / Split text based on ch...
Power Automate
Answered

Split text based on char type

(0) ShareShare
ReportReport
Posted on by 20

Hello All,

 

I want to split this text:

 

from this:

BRAVIA10458056700005349ATM John Doe 0580901 0.00 155,000.00 51,700,715.00

BRAVIA10458056700005349ATM John Doe 8980901 0.00 155,000.00 51,700,715.00

 

Into this:

List 1List 2List 3List 4
05809010.00155,000.0051,700,715.00
89809010.00155,000.0051,700,715.00

 

Please kindly suggest how can I achieve this? the only pattern is they start with 7 digits numbers.

 

Thank you before, any clue is appreciated.

I have the same question (0)
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You need to use Parse text with regular expressions enabled and use the following pattern to extract the relevant values first: \d{7}\s\d.+

    This will result in a list of matches with the following items:

    • 0580901 0.00 155,000.00 51,700,715.00
    • 8980901 0.00 155,000.00 51,700,715.00

    You can then loop through the list and use Split text on each item to split it by space. And then you can add it to your new lists.

     

    Here's a sample flow:

     

    Agnius_0-1689331364610.png

     

    And here's a snippet that you can copy and paste to your PAD designer to have those actions generated automatically for you:

    SET Text TO $'''BRAVIA10458056700005349ATM John Doe 0580901 0.00 155,000.00 51,700,715.00
    BRAVIA10458056700005349ATM John Doe 8980901 0.00 155,000.00 51,700,715.00'''
    Text.ParseText.RegexParse Text: Text TextToFind: $'''\\d{7}\\s\\d.+''' StartingPosition: 0 IgnoreCase: False Matches=> Matches
    Variables.CreateNewDatatable InputTable: { ^['Column1', 'Column2', 'Column3', 'Column4'], [$'''''', $'''''', $'''''', $''''''] } DataTable=> DataTable
    Variables.DeleteRowFromDataTable DataTable: DataTable RowIndex: 0
    LOOP FOREACH CurrentItem IN Matches
     Text.SplitText.Split Text: CurrentItem StandardDelimiter: Text.StandardDelimiter.Space DelimiterTimes: 1 Result=> TextList
     Variables.AddRowToDataTable.AppendRowToDataTable DataTable: DataTable RowToAdd: TextList
    END

     

    Note: I use a data table there, because that's a personal preference. If you need those values in lists, you can also create 4 separate lists and then add the values separately to each of them inside the loop. You can reference the values of %TextList% after using Split text by using an index as follows:

    Agnius_2-1689331631029.png

    Here's a snippet for this approach, too:

    SET Text TO $'''BRAVIA10458056700005349ATM John Doe 0580901 0.00 155,000.00 51,700,715.00
    BRAVIA10458056700005349ATM John Doe 8980901 0.00 155,000.00 51,700,715.00'''
    Text.ParseText.RegexParse Text: Text TextToFind: $'''\\d{7}\\s\\d.+''' StartingPosition: 0 IgnoreCase: False Matches=> Matches
    Variables.CreateNewList List=> List1
    Variables.CreateNewList List=> List2
    Variables.CreateNewList List=> List3
    Variables.CreateNewList List=> List4
    LOOP FOREACH CurrentItem IN Matches
     Text.SplitText.Split Text: CurrentItem StandardDelimiter: Text.StandardDelimiter.Space DelimiterTimes: 1 Result=> TextList
     Variables.AddItemToList Item: TextList[0] List: List1
     Variables.AddItemToList Item: TextList[1] List: List2
     Variables.AddItemToList Item: TextList[2] List: List3
     Variables.AddItemToList Item: TextList[3] List: List4
    END

     

    I personally prefer working with data tables, though, as it is cleaner and usually requires less actions.

     

    Alternatively, you can create the data table originally (my first sample) and add 4x Retrieve data table column into list actions after the loop to save the columns as lists like this:

    Agnius_1-1689331546295.png

    Here's the snippet for the 4 extra actions:

    Variables.RetrieveDataTableColumnIntoList DataTable: DataTable ColumnNameOrIndex: 0 ColumnAsList=> List1
    Variables.RetrieveDataTableColumnIntoList DataTable: DataTable ColumnNameOrIndex: 1 ColumnAsList=> List2
    Variables.RetrieveDataTableColumnIntoList DataTable: DataTable ColumnNameOrIndex: 2 ColumnAsList=> List3
    Variables.RetrieveDataTableColumnIntoList DataTable: DataTable ColumnNameOrIndex: 3 ColumnAsList=> List4

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution.
    If you like my response, please give it a Thumbs Up.

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • chillerbox Profile Picture
    20 on at

    Hi Agnius,

     

    Thank you for your response, it worked like wonder.  Do you happen to know how to get the text before the parsed one?

    "BRAVIA10458056700005349ATM John Doe" -> this text does not have any pattern and the length is dynamic.

     

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You could do that by modifying the regular expression pattern to .+\d{7}\s\d.+

    Doing so will essentially include everything that comes before the 7-digit number all the way since the previous newline.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • chillerbox Profile Picture
    20 on at

    Hi Agnius,

     

    Again, thank you for the reply. Right now, I'm using crop text to match the text before parsed text, but I will test your solution to see which is faster.

     

    chillerbox_0-1689655779956.png

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

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard