<?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: Remove characters in string using a variable in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213587#M7766</link>
    <description>&lt;P&gt;Besides the variable length slicing, which you appear to have figured out, what exactly are you trying to do with all of those replace statements?&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 21:00:00 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2022-09-16T21:00:00Z</dc:date>
    <item>
      <title>Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213433#M7762</link>
      <description>&lt;P&gt;I am trying to remove characters from a string but this Numeric value changes.&lt;/P&gt;&lt;P&gt;I'm passing in the string and the number of characters that should remain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below there are two ways I am trying this both doing the same thing... But the number of characters is hardcoded '75'&lt;/P&gt;&lt;P&gt;How do I replace the '75' with the variable 'characterLength' that is being passed into the def???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;newmod2 = newmod1[: &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;{characterLength}&lt;/STRONG&gt; &lt;/FONT&gt;]&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def fModifyValue(processResults, charlength):
        initialMod = str(processResults)
        characterLength = charlength
        newmod1 = initialMod.replace("u'", "")

        newmod2 = (newmod1[:75] + '..') if len(newmod1) &amp;gt; 75 else newmod1
        #OR 
        newmod2 = newmod1[:75]

        return newmod2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 15:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213433#M7762</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-09-16T15:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213435#M7763</link>
      <description>&lt;P&gt;Maybe&lt;/P&gt;&lt;P&gt;newmod2 = newmod1[: {} ].format(characterLength)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE:&amp;nbsp; Nope that does not work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 15:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213435#M7763</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-09-16T15:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213445#M7764</link>
      <description>&lt;P&gt;Ok think I got it.... BUT please if there is a better way please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def fModifyValue(processResults, charlength):
        initialMod = str(processResults)
        characterLength = int(charlength)
        newmod1 = initialMod.replace("u'", "").replace('[', '').replace(']', '').replace(r"'", r'')

        newmod2 = newmod1[:characterLength]

        return newmod2&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Sep 2022 15:33:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213445#M7764</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-09-16T15:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213587#M7766</link>
      <description>&lt;P&gt;Besides the variable length slicing, which you appear to have figured out, what exactly are you trying to do with all of those replace statements?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 21:00:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213587#M7766</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2022-09-16T21:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213819#M7770</link>
      <description>&lt;P&gt;Regular expressions are your friend here.&amp;nbsp; Check out the re module.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 14:38:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213819#M7770</guid>
      <dc:creator>DavidAnderson_1701</dc:creator>
      <dc:date>2022-09-19T14:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove characters in string using a variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213830#M7771</link>
      <description>&lt;P&gt;The data is coming in from a Word Press RestEP and a bit messy...&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 15:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-characters-in-string-using-a-variable/m-p/1213830#M7771</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2022-09-19T15:07:19Z</dc:date>
    </item>
  </channel>
</rss>

