AnsweredAssumed Answered

Arcade function to remove characters from string except numbers

Question asked by jbryant_wya on Mar 10, 2020
Latest reply on Mar 10, 2020 by jbryant_wya


I have a string field that contains both a test number and a Hydrant Test ID (alpha character) that I'm attempting to split into two separately returned values for a Survey123 URL Parameter. I'm currently using the Custom Attribute Display in the Pop-Up for the feature instead of calculating a new field (the feature layer is joined to a hosted table, so I can't create and calculate a new field).


The field values are formatted like this: 1, 1A, 1B, 2, 2A,......14, 14A, etc.

I'm trying to return both the Test Number (1, 2, 14) and the Hydrant ID (A, B, C, D, else "Flowing") separately.


Returning the ID I have figured out :


var HydrantID = Right($feature["WY_TestNum"], 1)

IIF($feature["WY_Status"]=="Flowing", "Flowing", HydrantID)


I thought I had the Test Number figured out using the Number function:




But this only works for the strings that only contain a number. Values like '1A' don't return anything ('NaN').


Is there a way to use the pattern parameter to return just the number values, even though my data pattern is not index-able from left to right?