How to split this string?

Hi Everyone,

I have one string value which I want to split based on the “,” and want to fill all these values
Tracking Number
Number of Items Missing or Damaged
Merchandise Description
Merchandise Value
Merchandise Value Currency
Consignee Name
Consignee Email Address
Consignee Phone Number

But the issue is when I’m using the split function it’s splitting all the values based on commas.

I must split the sentence into 8 parts which I have highlighted.

Could anyone please suggest a solution to this issue? It would be greatly appreciated.


looks like you have comma in only one field

so try like this


in this 0 will give first value(1Z9…),1 will give second(1) and 2 will give remaining(Kids girls…,1111111111111)

Now 2 should be split further

str1 = secondpiece.Split(","c).Last - this will give last values - 11111111111

Now use replace str2 = secondpiece.Replace(str1,"").Split({","},StringSplitOptions.None).Last - this will give ashley…com

Now use str3 = secondpiece.Replace(str2,"").Replace(str1,"").Split({","},StringSplitOptions.None).Last - this will give asley marsh

now use
str4 = secondpiece.Replace(str3,"").Replace(str2,"").Replace(str1,"").Split({","},StringSplitOptions.None).Last - this will give USD

finally replace all above remaning is the address you need

address = secondpiece.Replace(str4,"").Replace(str3,"").Replace(str2,"").Replace(str1,"").Trim(",")

Hope this helps


In such cases we can use Regex, Replace and can define patterns for inserting dedicated Split markers, finaly we split on the dedicated Split markers

Sample (condensed data)

so we split on #

How to do with string “1Z72A907YW00309983,2,ANF WOMENS JEANS,BLUE,24,ANF WOMENS JEANS,BLGR,24,180,USD,Lilah Gery,,1111111111”

the issue is that the highlighted area is not a fixed one. How to make it dynamic ?

will it work for this string also? If yes, could you please share the regex patten?

for your check


[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

turned to

Hi @Kumar_Sahu_Sameer

Can you try this

string rawInput = “I2910FR2YN00149875,1,kids GIRLS GRAPHICS,BLGR,13/14,16.16,USD,Ashley Marsh,,1111111111”
string processedInput = System.Text.RegularExpressions.Regex.Replace(rawInput, “[(.*?)]”, new System.Text.RegularExpressions.MatchEvaluator(Function(m) m.Value.Replace(“,”, “|”)))
string parts = processedInput.Split(“,“c)
For each loop of parts
parts(i) = parts(i).Replace(”|”, “,”)
Log message (269.7 KB)

Hope this helps

Thank you for the prompt response. Could you please guide me on creating the array of strings after the successful matching of the regex pattern?

In general we would do like:

strMarked = Regex.Replace
arrSplits = strMarked.Split("#"c)

Thank for looking into this but sadly I’m not getting the desired output

I am seeking this particular output as the desired result

Tracking Number : 1Z910FR2YN00149875
Number of Items Missing or Damaged : 1
Merchandise Description : kids GIRLS GRAPHICS,BLGR,13/14
Merchandise Value : 16.16
Merchandise Value Currency : USD
Consignee Name : Ashley Marsh
Consignee Email Address :
Consignee Phone Number : 1111111111

Can’t seem to connect with you properly. Could you send me the code if you don’t mind?

just share with us a textfile with the different variations, which you had indentified or which are expected

“1Z72A907YW00309983,2,ANF WOMENS JEANS,BLUE,24,ANF WOMENS JEANS,BLGR,24,180,USD,Lilah Gery,,1111111111”
This is the text and my requirement is

Tracking Number : 1Z72A907YW00309983
Number of Items Missing or Damaged : 2
Merchandise Value : 100
Merchandise Value Currency : USD
Consignee Name : Lilah Gery
Consignee Email Address :
Consignee Phone Number : 1111111111

Hi @Kumar_Sahu_Sameer

Can you try this (282.9 KB)

It looks like the thread turns into a ping-pong as the essential building blocks were shared along with training info

 "1Z72A907YW00309983,2,ANF WOMENS JEANS,BLUE,24,ANF WOMENS JEANS,BLGR,24,180,USD,Lilah Gery,,1111111111"
 strMarked = Regex.Replace(strText,strPattern, " $1#$2#$3#$4#$5#$6#$7#$8")
 " 1Z72A907YW00309983#2#ANF WOMENS JEANS,BLUE,24,ANF WOMENS JEANS,BLGR,24#180#USD#Lilah"
 arrSplits = strMarked.Split("#"c)
 string[8] { " 1Z72A907YW00309983", "2", "ANF WOMENS JEANS,BLUE,24,ANF WOMENS JEANS,BLGR,24", "180", "USD", "Lilah Gery", "", "1111111111" }

Done with:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

About associating the values with the Labels we do have different options. Have start and combine the marked string, with a header line and pass it to a Generate DataTable Activity


Did you try the above give logic at all?

that should suffice the requireement


Yes, I have tried this but got confused little bit.

Appreciate everyone’s prompt response. Thank you! :blush:

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