String Manipulation; everything except last element in array

Hello I am trying to get everything before the parentheses. What i did was split the string by spaces ( " "). How would I retrieve everything except the last element in the array

Transformers: The Last Knight (2017)

Thanks

1 Like

hi @aj52

below regex will help you to get the required string

RegEx : [^\s].*(?=\()

Regards
Ajay

1 Like

See this below workflow,
DivideStringSpace.xaml (8.5 KB)

Hi @aj52,

For this you can use take method on your array variable (like given below).

arrSTR = arrSTR.Take(arrSTR.Count - 1).ToArray()

here,

arrSTR β€”> is of type Array of String.
arrSTR.Take(arrSTR.Count - 1).ToArray() β€”> it’ll count items in a arrayVar and take out last item out of the array.

And using String.Join you can make 1 string of all items in array.

str1 (String) = String.Join(" ",arrSTR)

Note. you can use different separator. here I’ve used " " (one blank space).

Hi @aj52,

outputArray.Reverse.Skip(1)

OutputArray is result after split

Regards,
@HarshaBomidi

Hi @aj52,
Simple.

newStrVar= yourString.replace(yourString.split(" β€œC)(yourString.split(” β€œC). length-1),”")

It will remove the last item (2017) from the string.

Hope this will work for you!
Thanks!

1 Like