Trim a list


I have List of string, that I created using split string.


I have to delete spaces because it is like this now : one, two, three and needs to be one,two,three.

I dont see trim option or replace(" “,”"). What is the solution?

Best Regards,

Hi can you use this way

Listvariable.ForEach(Sub(element) element=element.Trim)


Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

Hi, like this?

ComponentsArray.ToList.ForEach(Sub(element) element=element.Trim)

It tells me: Expression does not produce a value.

Hi use in invoke code with language as

and pass the array or list as argument in invoke code


use an assign activity:
left side: yourNewListVar
right side:
yourOriginDataVar.Select(Function (x) x.Trim()).toArray

1 Like


Another solution
We can directly get trimmed string array as the following expression.

arrStr  = System.Text.RegularExpressions.Regex.Split(text.Trim,"\s*,\s*")


Hi Yoichu,

I get following error:


Can you replace text to Components (your variable name)?

arrStr  = System.Text.RegularExpressions.Regex.Split(Components.Trim,"\s*,\s*")


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