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)


1 Like

hi @aj52

below regex will help you to get the required string

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


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()


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 is result after split


Hi @aj52,

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!

1 Like