I have a python script to remove the text in parentheses for labeling, and I cannot figure out how to convert it to work with Arcade. (I did not write this script, but I am trying to get the same results in AGOL.
The Python script is: def FindLabel ( [label] 😞
S =[label].strip()
i = S.find('(')
if i == -1:
return S.replace('::','\n')
elif i > 0:
return S[0:i]
I know that Arcade does not have a strip function, so I was trying trim, and instead of the newline function, I was just typing a space.
Example: '82 (Globe)' needs to be '82'
Thank you in advance.
Joan
Solved! Go to Solution.
You can use the Arcade Split function.
var array = split($feature.field, "(")
return array[0]
You can use the Arcade Split function.
var array = split($feature.field, "(")
return array[0]
That worked. Thank you so much!
Joan
A small addition to the solution provided by Ken: if you are interested in returning a numeric value, you might want to explicitely convert it to a number. Also the text you return would have a space at the end, since split on "(" will result in an array with two elements: "82 " and "Globe)". To avoid this you could include the Trim and Number functions, like this:
var array = Split($feature.field, "(");
return Number(Trim(array[0]));
Got it. Thank you for the additional information.
Joan