Split string and remove last 2

I’ve split a string based on the space but how do I remove the last 2 elements? Able to remove the first element by just replacing (0) with “”. But stuck on the replacing the last 2

1 Like

You can do this with a simple assign activity as follows: YourArray = YourArray.Take(YourArray.length - 2).ToArray

EDIT: You can expand this to also remove the first element of the array as follows: Assign YourArray = YourArray.Take(YourArray.length - 2).Skip(1).ToArray

The order of the Take/Skip is important, you’ll want to Take first, then Skip

1 Like

Hi this part is confusing. Initially reading from pdf, the line is a string of text. e.g. “This event is on the Friday.” As I only want “Event is on”, hence I use .Split() so as to separate them into elements.But how do i string to array

@TyraS

As you said, you are splitting the text based on space right. It will generate output as array of string. And then use that expression @Dave mentioned in previous post.

@TyraS

Welcome to the community.

Maybe this article might be helpful to you.

cheers :smiley:

Happy learning :smiley:

1 Like

I see i got it now. thanks alot! @lakshman @Dave

1 Like

Thanks !! i understood now

1 Like

Yey Great @TyraS

cheers :smiley:

Happy learning :smiley:

1 Like

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