Hi there.
I'm struggling to remove null/empty elements from a string array. I can't find a way to remove such elements without sorting or converting to unique set. I will appreciate any hints how can I do the above operation.
Example code:
string source_string = "testelem1,,testelem2,,,testelem3,testelem2";
string[] my_array = split(source_string, ",");
I have tried :
- deleteElement(my_array, "")
- deleteElement(my_array, "null")
- deleteElement(my_array, null)
None of the above worked.
So far the I have found only two possibilities, both messing up order of elements in original array thus not fitting my needs:
- sort array, loop check 0th element for isNull() and remove it with deleteElementAt if true
- convert to set of unique elements by arrayToSet, check 0th element if isNull() and remove it with deleteElementAt if true.