<?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 Re: Removing leading zeroes from integer part of string using Arcade in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207635#M59235</link>
    <description>&lt;P&gt;It supports string addition and iterating through a string. You can implement isdigit yourself.&lt;/P&gt;&lt;P&gt;This would be a literal translation:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var a = "XXXX_0045KM"
var digits = []
for(var i in a) {
    var ai = Text(Number(a[i]))
    if(ai != "NaN") {
        Push(digits, ai)
    }
}
return Number(Concatenate(digits, "")) + " km"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be a good (albeit lengthy) way to extract all digits. In this case, the relevant digits are in defined positions. This would actually return wrong results if there are digits in the XXXX part.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 12:32:50 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-08-30T12:32:50Z</dc:date>
    <item>
      <title>Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207541#M59225</link>
      <description>&lt;P&gt;I am using ArcGIS Pro 3.0.1 and Arcade.&lt;/P&gt;&lt;P&gt;I have a text field named RouteName with an example value of "XXXX_0045KM" and I need to do three things to its values:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;left strip the leading zeroes from the number part;&lt;/LI&gt;&lt;LI&gt;remove the underscore and anything left of that; and&lt;/LI&gt;&lt;LI&gt;make the "KM" part lowercase.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I can do the 2nd and 3rd parts using the code below but is there a way to remove (left strip) any leading zeroes before the number part using Arcade?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var arrName = split($feature.RouteName,"_")
return Lower(arrName[1])&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately, I cannot just switch to using the Python Parser because I am using this with&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/attribute-driven-symbology.htm#" target="_blank"&gt;Attribute-driven symbology—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;as part of labeling measured hatches along lines.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 03:25:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207541#M59225</guid>
      <dc:creator>GraemeBrowning_Aurizon</dc:creator>
      <dc:date>2022-08-30T03:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207563#M59229</link>
      <description>&lt;P&gt;The way that I found I could do this is:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var arrName = split($feature.RouteName,"_")
var numKM = Number(Left(arrName[1],4))
return numKM + "km"&lt;/LI-CODE&gt;&lt;P&gt;The trick was to use Left to get the characters that represented a zfilled integer and convert them to a Number.&amp;nbsp; The Number function stripped off the leading zeroes automatically.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 05:53:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207563#M59229</guid>
      <dc:creator>GraemeBrowning_Aurizon</dc:creator>
      <dc:date>2022-08-30T05:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207596#M59233</link>
      <description>&lt;P&gt;If your values are all formatted the same way, you can also use the Mid() function:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var num = Number(Mid($feature.RouteName, 5, 4))
return num + " km"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have differing formats (eg also routes with 5 or 3 digits), you can use the Replace() function:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var txt = Split($feature.RouteName, "_")[1]
var num = Number(Replace(txt, "KM", ""))
return num + " km"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 08:39:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207596#M59233</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-30T08:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207617#M59234</link>
      <description>&lt;P&gt;does Arcade support python-like string functions?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;a
'XXXX_0045KM'

str(int("".join([i  for i in a if i.isdigit()])))
'45'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The syntax have to be emulated&amp;nbsp; in Arcade of course&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 10:33:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207617#M59234</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-08-30T10:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207635#M59235</link>
      <description>&lt;P&gt;It supports string addition and iterating through a string. You can implement isdigit yourself.&lt;/P&gt;&lt;P&gt;This would be a literal translation:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var a = "XXXX_0045KM"
var digits = []
for(var i in a) {
    var ai = Text(Number(a[i]))
    if(ai != "NaN") {
        Push(digits, ai)
    }
}
return Number(Concatenate(digits, "")) + " km"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be a good (albeit lengthy) way to extract all digits. In this case, the relevant digits are in defined positions. This would actually return wrong results if there are digits in the XXXX part.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:32:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207635#M59235</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-30T12:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207637#M59236</link>
      <description>&lt;P&gt;Just had another look at the docs: &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#number" target="_blank" rel="noopener"&gt;Number()&lt;/A&gt; also supports a format string. So if the part after the underscore is the same for all features, here is another possibility:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Number(Split($feature.RouteName, "_")[1], "####KM") + " km"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1207637#M59236</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-30T12:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading zeroes from integer part of string using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1603894#M94762</link>
      <description>&lt;P&gt;Thank you all this helped me today!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 18:21:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-zeroes-from-integer-part-of/m-p/1603894#M94762</guid>
      <dc:creator>AndreaB_</dc:creator>
      <dc:date>2025-04-08T18:21:54Z</dc:date>
    </item>
  </channel>
</rss>

