How to remove extra commas in middle of the string in uipath

Hi All,

I am reading excel and saving output in dt.
I want to pass all the values in dt comma-separated string to execute sql query
i am using below approach

DirectoryList=(from row in directoryNumberDt.AsEnumerable select Convert.ToString(row.Item(“Telephone Number”))).ToList
strDirectoryNumber=String.Join(“,”,DirectoryList).Trim
It was working fine but now iam getting issue like below:
comma extra

Can some one help me to reslove this issue.New Microsoft Excel Worksheet.xlsx (11.0 KB)

Hi @thima,

You could implement a code that replaces “,” with “,” and use an integer to count down, like so:

The replace code will be this: VariableName = VariableName.Replace(",,",",")

Use this below code to remove extra commas, @thima
System.Text.RegularExpressions.Regex.Replace(YourString,“,{2,}”,“,”, RegexOptions.Multiline).
Hope this may help you :slight_smile:

Hi Manish,
Getting below error
image

Thanks i got it.

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