<?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 Not sure on functionality needed for AGOL popup expression in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577420#M63246</link>
    <description>&lt;P&gt;Hello, I am working with a field that includes numeric values as a string that appear like this:&amp;nbsp;&lt;SPAN&gt;0820;0830;0840;0850;0860;0870A;0880;0890;1050;1060;1070;1080;1100;1110;1120;1140;1150;1160.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I would like to do is separate each value on a new line and remove leading zero/one trailing zero in my popup. I am working with the arcade script below. So far the script is working as I get a list like the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OliviaMancuso_0-1737470967536.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123664i30E8C31F7ED861ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OliviaMancuso_0-1737470967536.png" alt="OliviaMancuso_0-1737470967536.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the problem I am having is that I don't know how to deal with values that also include a letter. In those rare cases, it can be any letter (always at the end), and I don't know how to remove the zero that is to the left of the letter. So right now in the resulting list it looks like 870A when I would like it to look like 87A.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OliviaMancuso_1-1737471024892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123665iBC4289E4D5F1D9DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OliviaMancuso_1-1737471024892.png" alt="OliviaMancuso_1-1737471024892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I cannot claim to have written the script below as I am very new to arcade. I was using Esri's AI assistant to help form the script. But I was not having any luck with the more complicated value mentioned above. Any advice that could be provided would be much appreciated. Thanks!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var inputString = $feature.OrdConcat;
var values = Split(inputString, ";");
var result = [];

for (var i in values) {
    var cleanedValue = values[i];
    
    // Remove the first leading zero
    if (Left(cleanedValue, 1) == "0") {
        cleanedValue = Mid(cleanedValue, 1, Count(cleanedValue) - 1);
    }
    
    // Check if the last character is a letter
    if (IsNan(Right(cleanedValue, 1))) {
        // Check if the character before the letter is a zero
        if (Mid(cleanedValue, Count(cleanedValue) - 2, 1) == "0") {
            cleanedValue = Left(cleanedValue, Count(cleanedValue) - 2) + Right(cleanedValue, 1);
        }
    } else if (Right(cleanedValue, 1) == "0") {
        // Remove exactly one trailing zero if no letter is present at the end
        cleanedValue = Left(cleanedValue, Count(cleanedValue) - 1);
    }
    
    Push(result, cleanedValue);
}

return Concatenate(result, TextFormatting.NewLine);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 14:55:57 GMT</pubDate>
    <dc:creator>OliviaMancuso</dc:creator>
    <dc:date>2025-01-21T14:55:57Z</dc:date>
    <item>
      <title>Not sure on functionality needed for AGOL popup expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577420#M63246</link>
      <description>&lt;P&gt;Hello, I am working with a field that includes numeric values as a string that appear like this:&amp;nbsp;&lt;SPAN&gt;0820;0830;0840;0850;0860;0870A;0880;0890;1050;1060;1070;1080;1100;1110;1120;1140;1150;1160.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I would like to do is separate each value on a new line and remove leading zero/one trailing zero in my popup. I am working with the arcade script below. So far the script is working as I get a list like the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OliviaMancuso_0-1737470967536.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123664i30E8C31F7ED861ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OliviaMancuso_0-1737470967536.png" alt="OliviaMancuso_0-1737470967536.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the problem I am having is that I don't know how to deal with values that also include a letter. In those rare cases, it can be any letter (always at the end), and I don't know how to remove the zero that is to the left of the letter. So right now in the resulting list it looks like 870A when I would like it to look like 87A.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OliviaMancuso_1-1737471024892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123665iBC4289E4D5F1D9DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OliviaMancuso_1-1737471024892.png" alt="OliviaMancuso_1-1737471024892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I cannot claim to have written the script below as I am very new to arcade. I was using Esri's AI assistant to help form the script. But I was not having any luck with the more complicated value mentioned above. Any advice that could be provided would be much appreciated. Thanks!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var inputString = $feature.OrdConcat;
var values = Split(inputString, ";");
var result = [];

for (var i in values) {
    var cleanedValue = values[i];
    
    // Remove the first leading zero
    if (Left(cleanedValue, 1) == "0") {
        cleanedValue = Mid(cleanedValue, 1, Count(cleanedValue) - 1);
    }
    
    // Check if the last character is a letter
    if (IsNan(Right(cleanedValue, 1))) {
        // Check if the character before the letter is a zero
        if (Mid(cleanedValue, Count(cleanedValue) - 2, 1) == "0") {
            cleanedValue = Left(cleanedValue, Count(cleanedValue) - 2) + Right(cleanedValue, 1);
        }
    } else if (Right(cleanedValue, 1) == "0") {
        // Remove exactly one trailing zero if no letter is present at the end
        cleanedValue = Left(cleanedValue, Count(cleanedValue) - 1);
    }
    
    Push(result, cleanedValue);
}

return Concatenate(result, TextFormatting.NewLine);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 14:55:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577420#M63246</guid>
      <dc:creator>OliviaMancuso</dc:creator>
      <dc:date>2025-01-21T14:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Not sure on functionality needed for AGOL popup expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577431#M63247</link>
      <description>&lt;P&gt;In line 14, you're checking if a string is a NaN. That will return false, since the function IsNAN evaluates if a value is a NaN according to these rules:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;A number is considered NaN in one of the following scenarios: - 0/0 - Infinity / Infinity - Infinity * 0 - Any operation in which NaN is an operand - Casting a non-numeric text or undefined to a number&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So what you have to do is to attempt to cast that last character as a Number and check if it's a NaN. This will return the list as you wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var inputString = $feature.OrdConcat;
var values = Split(inputString, ";");
var result = [];

for (var i in values) {
  var cleanedValue = values[i];

  // Remove the first leading zero
  if (Left(cleanedValue, 1) == "0") {
    cleanedValue = Mid(cleanedValue, 1, Count(cleanedValue) - 1);
  }

 // Check if the last character is a letter
  if (IsNan(Number(Right(cleanedValue, 1)))) {

    // Check if the character before the letter is a zero
    if (Mid(cleanedValue, Count(cleanedValue) - 2, 1) == "0") {
      cleanedValue = Left(cleanedValue, Count(cleanedValue) - 2) +
      Right(cleanedValue, 1);
   }
  } else if (Right(cleanedValue, 1) == "0") {
    // Remove exactly one trailing zero if no letter is present at the end
    cleanedValue = Left(cleanedValue, Count(cleanedValue) - 1);
  }

  Push(result, cleanedValue);
}

return Concatenate(result, TextFormatting.NewLine);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:00:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577431#M63247</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-01-21T16:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Not sure on functionality needed for AGOL popup expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577461#M63250</link>
      <description>&lt;P&gt;That is working perfectly! Thank you for the help, it is much appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here are the results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OliviaMancuso_0-1737480105490.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123666i969EE3E27FB36B5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OliviaMancuso_0-1737480105490.png" alt="OliviaMancuso_0-1737480105490.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 17:22:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/not-sure-on-functionality-needed-for-agol-popup/m-p/1577461#M63250</guid>
      <dc:creator>OliviaMancuso</dc:creator>
      <dc:date>2025-01-21T17:22:03Z</dc:date>
    </item>
  </channel>
</rss>

