Hello! Is there an Arcade function I can use that will display in the labels just the numbers in an address field? The address field that I have on a particular layer has the number and street name together. The labels I want to create for that layer just need the address number displayed. Thank you.
Solved! Go to Solution.
I don't know what your address data looks like, but assuming there's a space between the numbers and the street name, you could try using Split.
var addr = '1223 S Main St'
return Split(addr, ' ', 1)[0]
By including the limit argument, the function stops splitting after the first space and returns a single-item array, so we use "[0]" to pull out that value. The above code returns:
RESULT: '123'
TYPE: String
As long as the address numbers come first, this will consistently grab them, and won't give you odd results if a road has numbers in its name, such as 'Route 47'. The only time it wouldn't work is if you have a half address, like '4408 1/2 S Benjamin Rd'.
I don't know what your address data looks like, but assuming there's a space between the numbers and the street name, you could try using Split.
var addr = '1223 S Main St'
return Split(addr, ' ', 1)[0]
By including the limit argument, the function stops splitting after the first space and returns a single-item array, so we use "[0]" to pull out that value. The above code returns:
RESULT: '123'
TYPE: String
As long as the address numbers come first, this will consistently grab them, and won't give you odd results if a road has numbers in its name, such as 'Route 47'. The only time it wouldn't work is if you have a half address, like '4408 1/2 S Benjamin Rd'.
John,
Along the same exact lines as the above example, could we use the Split function to grab the street name instead of the street number? Anything after the space essentially.
Thanks,
Adam Levine
SUNY Cortland
For sure! Again, assuming the data is consistently formatted, you could just use
return Split(addr, ' ', 1)[1]
to get anything after the space.
John,
Thanks so much!
Adam
Josh, that worked perfectly! thank you so much!