Question:
So what I am trying to achieve is selecting all words from a given string, except the last one.
So I have a few strings;
1 2 3 4 |
On The Rocks The Rocks Major Bananas |
I want to select all words, except the last one from every string.
I figured out I could use split() to take every word as separate. Though I can’t figure it out any further.
Thanks in advance.
Answer:
Here’s how I might do something like this.
1 2 3 4 |
$Sample = "String sample we can use" $Split = $Sample.Split(" ") [string]$split[0..($Split.count-2)] |