<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Arcade function to remove characters from string except numbers in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145537#M7121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field values are formatted like this: 1, 1A, 1B, 2, 2A,......14, 14A, etc.&lt;/P&gt;&lt;P&gt;I'm trying to return both the Test Number (1, 2, 14) and the Hydrant ID (A, B, C, D, else "Flowing") separately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Returning the ID I have figured out :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var HydrantID = Right($feature["WY_TestNum"], 1)&lt;/P&gt;&lt;P&gt;IIF($feature["WY_Status"]=="Flowing", "Flowing", HydrantID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I had the Test Number figured out using the Number function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number($feature.WY_TestNum)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this only works for the strings that only contain a number. Values like '1A' don't return anything ('NaN').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Mar 2020 21:46:05 GMT</pubDate>
    <dc:creator>JoeBryant1</dc:creator>
    <dc:date>2020-03-10T21:46:05Z</dc:date>
    <item>
      <title>Arcade function to remove characters from string except numbers</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145537#M7121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field values are formatted like this: 1, 1A, 1B, 2, 2A,......14, 14A, etc.&lt;/P&gt;&lt;P&gt;I'm trying to return both the Test Number (1, 2, 14) and the Hydrant ID (A, B, C, D, else "Flowing") separately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Returning the ID I have figured out :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var HydrantID = Right($feature["WY_TestNum"], 1)&lt;/P&gt;&lt;P&gt;IIF($feature["WY_Status"]=="Flowing", "Flowing", HydrantID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I had the Test Number figured out using the Number function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number($feature.WY_TestNum)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this only works for the strings that only contain a number. Values like '1A' don't return anything ('NaN').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2020 21:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145537#M7121</guid>
      <dc:creator>JoeBryant1</dc:creator>
      <dc:date>2020-03-10T21:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade function to remove characters from string except numbers</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145538#M7122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/352743" target="_blank"&gt;Joe Bryant&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way you could approach this would be to define your own function that iterates through the characters in a string and returns only the characters that are found to be numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example below I'm testing each character of the string individually to see the Number function returns NaN - then constructing a new string from only characters where a Number() actually returned a number.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;function ExtractNumbers(string){
    var result = "";
    for (var i=0; i&amp;lt;Count(string); i++){
        if(!isNan(Number(string&lt;I&gt;))){
            result += string&lt;I&gt;;
        }
    }
    return result; 
}

ExtractNumbers("1A");&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/I&gt;&lt;/CODE&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:57:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145538#M7122</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade function to remove characters from string except numbers</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145539#M7123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks James! That absolutely worked!&lt;/P&gt;&lt;P&gt;It was also a lot more difficult than I expected. I'll have to save that function as I doubt I could write it from scratch.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2020 22:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-function-to-remove-characters-from-string/m-p/145539#M7123</guid>
      <dc:creator>JoeBryant1</dc:creator>
      <dc:date>2020-03-10T22:22:25Z</dc:date>
    </item>
  </channel>
</rss>

