How To Get Data From Filter Array Of Strings

Hi Guys,

I would want to filter data from array of list like example below , how can I do that on Uipath thanks for answers.

CN=ABC,OU=A,OU=AB,OU=Agents,DC=B,DC=int
CN=XYZ,OU=B,OU=BD,OU=Agents,DC=B,DC=int,
CN=XYZ,OU=C,OU=EF,DC=B,DC=int,
CN=EDF,OU=D,DC=B,DC=int

I would want to filter only CN values in this array of list. I try some assign commands but not worked.

Thanks for help

some details are not clear. give a try on

arrYourVar.Where(Function (x) x.StartsWith("CN=")).toArray

What is “x” in function ? :slight_smile:
Thanks

its just for assigning you can use whatever you need @burakavuncu

Regards
Sudharsan

Hi ,

It shows like that, how can ı get only “CN” values this. I need only get values from CN parameter in this array of list.

image

Hi @burakavuncu ,

We would like to know more about the type of the Data provided, You did mention it is an Array of List. If that is the case, Could you Show us the Variable Panel to which variable this value is Stored ?

Or Let us know if the Data is in the Text/String format.

Yes,

I get array of list from Active Directory and after that I assing this values coming from AD to string.join list.

Okay so this is one list of string right? or this list of<System.String(array)>?

Regards
Sudharsan

It’s system.string

just dump the variable within the immediate panel during a debug and share it with us. This would be fast way to share with us essential details

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

It’s like that;

ok, thanks
give a try on adopted statement

When splits are needed

arrYourVar.SelectMany(Function (x) x.Split(","c)).Where(Function (x) x.StartsWith("CN=")).toArray

when not splits are needed:

arrYourVar.Where(Function (x) x.StartsWith("CN=")).toArray

you can prototype it also directly within the immediate panel

When I try it , it returns like that;

I need to filter only CN values.

yes because you did not use within immediate panel.

Adding a toString to a String array will result on this.

Immediate panel is faster for checking otherwise you need to join the values:

String.Join("|",arrYourVar.SelectMany(Function (x) x.Split(","c)).Where(Function (x) x.StartsWith("CN=")).toArray )

Its worked dude.

Thanks so much^^

Ând last question how can I write each “CN” newline ? Is it possible ?

image

Instead of “|” in the expression use Environment.NewLine @burakavuncu

String.Join(Environment.NewLine,arrYourVar.SelectMany(Function (x) x.Split(","c)).Where(Function (x) x.StartsWith(“CN=”)).toArray )

Regards
Sudharsan

1 Like

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