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

1 Like

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

1 Like

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

33 Likes

Kudos @Tilak_Divakar, this worked.

1 Like

i have the string
11:30
05:30
10:56
.
.
.
I am add data row for this but in data table it create the 1 empty string…for each item of string
any solution…

1 Like

I can confirm that this solution worked for me on an Array of Strings

6 Likes

@Tilak_Divakar Yes thanks a lot…this really worked …for both array and list of string …thanks a lot

1 Like

Thank you @Tilak_Divakar works perfectly!

1 Like

It worked for m too…Thanks