Separate newline string with comma

Hi, I have a string as below format.


I want to change the string format to

Strawberry, Apple, Mango, Blueberry.

Can anyone help me how can I do that ?


For this try this way

  1. Use assign activitiy to split the string and assign to string array

Let’s say string is stored in str1 varaible

list_1 = Split(str1, Environment.NewLine)

Then use another assign to intialise a string varaible

result = “”

Next use for each activitiy to loop each element of array (for each item in array)

Next in property section of for each create a varaible in the index property section which shows the no of iteration going on let’s say variable name is index

The inside the for each use the following assign activity
Use if Condition with condition as index =0

If it is true then in then section use the following assign activity

result = result+item

If it is false in else section use the assign activity

result = result+“,”+item

Then outside the for each loop use message to display result varaible

Hope it helps

Mark it as solution if it helps to answer ur query


Nived N :robot:

Happy Automation


Thank you. Able to solve it

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.