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.
Five minutes in the ESRI Arcade playground and I came up with this:
var name = ' R3-1';
Console(name)
var nameArray = Split(name,'-')
Console(nameArray)
var arrayLength = Count(nameArray)
Console(arrayLength)
if (arrayLength == 2) {
Console(nameArray[0])
}
The Console() function is like the print() function in python, but it only works in the playground. This is nothing more than python logic in Arcade...
Care to share?
Here:
(I did not write this)
var ZoneCodeName = $feature.CENTROID;
var ZoneCodeFndDash = Find('-', ZoneCodeName, 0);
var ZoneCodeFndLBracket = Find('(', ZoneCodeName, 0);
var Char1 = Mid(ZoneCodeName,0,1);
var Char2 = Mid(ZoneCodeName,1,1);
if (Char1=="H"){
var ZoneCodeCount = Count(ZoneCodeName);
var ZoneCodeName = Mid(ZoneCodeName, 2, ZoneCodeCount);
var ZoneCodeFndDash = Find('-', ZoneCodeName, 0);
var ZoneCodeFndLBracket = Find('(', ZoneCodeName, 0);
if (ZoneCodeFndDash!=-1){
var ZoneCodePre = Mid(ZoneCodeName, 0, ZoneCodeFndDash);
return ZoneCodePre;
}
if (ZoneCodeFndLBracket!=-1){
var ZoneCodePre = Mid(ZoneCodeName, 0, ZoneCodeFndLBracket);
return ZoneCodePre;
}
return ZoneCodeName;
}
if (ZoneCodeFndDash!=-1){
var ZoneCodePre = Mid(ZoneCodeName, 0, ZoneCodeFndDash);
return ZoneCodePre;
}
if (ZoneCodeFndLBracket!=-1){
var ZoneCodePre = Mid(ZoneCodeName, 0, ZoneCodeFndLBracket);
return ZoneCodePre;
}
return ZoneCodeName;