Scenario 1: First you need to split the array delimited by comma
Scenario 2: Use String.Join() to append the the string that you want but of course use foreach for the array of string.
Hello @mohininemade301094
if you are ok with replacing single comma in you item i.e ( “Note: , First Line,this is contact detail of T”) with any other char… then you can try below
String str = original string
String strMatch = System.Text.RegularExpressions.Regex.Match(str, chr(34) & "(.*)" & chr(34)).ToString
for each item in str.Replace(strMatch,strMatch.Replace(",","")).Split(","c)
log message (item)
next item
@mohininemade301094 - you should use Regex.Split for this instead of the normal string.split. This will allow you to isolate the commas to be only those outside of quotation marks. This regex code should grab all commas outside of the quotes (?!\B"[^"]*),(?![^"]*"\B)
I tested this out using your original string: FirstName,LastName,Mr,T,"Note: , First Line,this is contact detail of T" I used Regex.Split(YourString,RegexPattern) and got an array of 5 strings as follows:
FirstName
LastName
Mr
T
“Note: , First Line,this is contact detail of T”
EDIT: the string you have written in the first post won’t work with my regex pattern because it is using weird double quotes. If it does indeed use those weird double quotes, you should use this regex pattern instead: (?!\B("|“|”)[^("|“|”)]*),(?![^("|“|”)]*("|“|”)\B)
Also, the pattern will struggle if there are multiple double quotes it is searching through. If you have the possibility that it will contain multiple double quotes in your input string (e.g. Mr,T,“Test,1”,Address,“Details,here”) then you should first split by finding every second double quote, then run the regex split mentioned in my comment here
@mohininemade301094 - I thought it was going to struggle with multiple double quotes but it is not. I tested it a few times and it had no issues. It only split on the commas that were outside of double quotes. (?!\B("|“|”)[^("|“|”)]*),(?![^("|“|”)]*("|“|”)\B)
Yes uipath doesn’t like the double quotes. You have to escape them with even more double quotes which is incredibly annoying and hard to read. Change the regex pattern to be this (copy+paste it): "(?!\B(""|"“|"”)[^(""|"“|"”)]*),(?![^(""|"“|"”)]*(""|"“|"”)\B)"
It is not working for input string
“, , , , , , , , , ,“”“”,myemail,c@ny.com,myaddress,”“2323street, line1315 text, AK 52525 “”,”“term”“,”“ny”“,123,456,3652”
Is that an input string that you are putting in uipath manually? Or is that how it will actually look from the application? There are tons of double quotes in there so it’s really hard to tell. Dealing with all of the escaping double quotes makes putting sample data to test within uipath a huge pain. I would instead create .txt files that emulate exactly how the input string will look in production.
So if in production it looks like this: 123,"1ti,13k",1kd,1k,test then just put exactly that in a notepad file and use the read text file activity to grab the input string. If you did in UiPath you have to make the input string "123,""1ti,13k"",1kd,1k,test" so it’s confusing trying to decipher.