Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: stonysmithThe code below should work for you.
I've added a bit to catch addresses such as this:
12345 Main Street, Los Angeles, CA, 90210
This would not properly handle.
12345 Main Street, APT 98765, Los Angeles, CA, 90210
You'll need to add another IF to handle 5 digit apartments.
x = regexMatch(Address, "\\d{5}")
if len(x)>1 then y=x[1][0].str() else y=x[0][0].str()
emit y