Trim a list

Hi,

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

image

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,
LC

Hi can you use this way

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

Regards

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 vb.net

and pass the array or list as argument in invoke code

@logan.capp

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

1 Like

Hi,

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

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

Regards,

Hi Yoichu,

I get following error:

Hi,

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

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

Regards,

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