Getting Unique Values from a List of Strings

Hi There,

Here is an example of a list of Strings that I have


Testing123, Testing 124

Testing123, Testing 890"

Basically what I’d like to do is get each unique value, into this list of strings, without the commas in between - there can be various combinations of the above, but in the end ideally I would have a list with individual strings of:

Testing 890”

So some of the strings have a comma and may have one of the previous values also, but I would like no duplicates in the end list.

Any help would be greatly appreciated!

the simple option

listDistinct = listVar.Distinct().toList

1 Like

Hi @Kyleb91 ,

Maybe we would need to check on some more of the sample data as there are various combinations to be handled. Currently, we see that strings can be present in new lines and also maybe separated by commas.

1 Like

Thanks man yes, but some of these strings contain 2 names, and one of the strings with only one name, may be in the other one, but in a combination, so I am trying to get all of same strings separated too…

Yes indeed - I suppose what I need first is a regex expression to get the text from each string - as before this I am basically adding these from a datatable…

Lets assume the following String (with Line Breaks, empty lines)


We can split

We also to the second split on the comma and trim the value

If needed the String Collection result can also later be joined e.g. String.Join method

1 Like

Thanks man - let me just clarify that the list is

“Testing 123”,

Testing 124",

Testing 890"


please show us variable output as screenshot from the immediate panel, Thanks

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


So ideally the above list would be “Test01”, “Test03”, “Test02”

We split, Trim and distinct like:

1 Like

Bravo Sir @ppr :slight_smile: Thanks a million!

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