Removing all Empty or null Strings from a String Array, no looping

I have a String array, how do I clear all empty and null strings from this?

Edit: No looping/iterating please (process in bulk)

Hi @DEATHFISH

Set strvar=string.empty

Thanks
Ashwin.S

Sorry how do i use String.empty to clear array items which are null or empty string? What activity do i use

Hi @DEATHFISH

Check this

I want remove strings from array specified by index

Thanks
Ashwin.S

I am not looking to remove strings from array based on index

I don’t know which index items I want to remove, only know that if they are blank or null I want to remove these

E.g.

String1
null
String2
String3
String4
" "
null
String5

I want to remove all these blank or null entries regardless of where they are within the array

Thanks

Hi @DEATHFISH,
1.Iterate the array using for each activity and check if condition if it is null or empty.
2.If it is not null or empty then move to the other array.
3.Then you will have only not null and empty values.
Cheers.
Vashisht.

How do I do this without looping?

i.e. need a method to bulk remove all empty or null items

I used

arr.ToList.RemoveAll(Function(str) String.IsNullOrEmpty(str))

somehow UiPath is reading this expression as an integer

Any idea on how to fix this?

Any help?

This worked for me:
arr.Where(Function(x) Not String.IsNullOrWhiteSpace(x)).ToArray

1 Like

Kudos @Tilak_Divakar, this worked.