Hi all,
I am extremely new at using attribute rules and Arcade for ArcGIS Pro, and I need some help on what I am sure is a simple process.
I have a column filled with text like this, "R4-52" and "H-R4-52" What I would like to do is use arcade to populate a new field where the output will be "R4", basically removing the dash and any characters before and after the dash. I know the replace function can be used to do this, but I wasn't able to find any examples.
Can someone help with this?
Much appreciated,
Justin
Solved! Go to Solution.
What about the left() function?
Are you looking for the exact value, 'R4'?
Then, check the following syntax
Parser: Arcade
IIF(FIND('R4',$feature.FIELDNAME,0)==-1,'','R4')
Let me know a few more examples if the substring value is dynamic.
Thanks for the reply!
The values are dynamic, my apologies.
I basically would like to remove the <text>"-" , "-'<text> and keep the middle characters.
Thanks for the help!
Do you have one "-" or more than two "-" instances in the string? What to do in those cases?
e.g.: HE-77-L-0
Just one and two dashes
eg: R3-1, and H-R4-2
Parser: Arcade
SPLIT($feature.FIELDNAME,'-')[-2]
I thought this is in the context of an Attribute Rule; in that case Arcade is the only option.
Ahh. I see. Removed the Python one.
Thanks.
Another approach: split the string at the dashes into an array and then get the count of that array. If the count indicates 1 dash, grab the first element of the array; if the count indicates 2 dashes, grab the second element of the array. I'm pretty sure arcade arrays are 0 based.