<?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: Label class expression to strip words in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/label-class-expression-to-strip-words/m-p/802660#M265</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/310692" target="_blank"&gt;Lisa,&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One quick way using python is the following code.&amp;nbsp; You can customize the list of words to be striped from your string.&amp;nbsp; Please do note, this particular rendition is case-sensitive so 'Branch' is not he same as 'branch' and the latter would not be removed. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;string &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Weston Ranch Branch Library"&lt;/SPAN&gt;
stripList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Library'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Branch'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; string&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; stripList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a label expression it would be along the lines of the following and you would replace [string] with the name of your attribute:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="455275" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/455275_Capture.PNG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:19:33 GMT</pubDate>
    <dc:creator>LanceCole</dc:creator>
    <dc:date>2021-12-12T09:19:33Z</dc:date>
    <item>
      <title>Label class expression to strip words</title>
      <link>https://community.esri.com/t5/python-snippets-questions/label-class-expression-to-strip-words/m-p/802659#M264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Novice in python. Have tried several expressions but can't seem to strip the words 'Branch' and/or 'Library' from a field of names...some names are "[name of city] Branch Library" and others are "[name of city] Library". I don't want my labels to show either of these on the map because it looks too busy. Some of the city names contain the string "Ranch" so those were also getting stripped - for example if the name is "Weston Ranch Branch Library" I only want the label to be "Weston Ranch" or if the name was "Weston Library" only display "Weston."&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2019 20:28:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/label-class-expression-to-strip-words/m-p/802659#M264</guid>
      <dc:creator>LS1</dc:creator>
      <dc:date>2019-08-05T20:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Label class expression to strip words</title>
      <link>https://community.esri.com/t5/python-snippets-questions/label-class-expression-to-strip-words/m-p/802660#M265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/310692" target="_blank"&gt;Lisa,&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One quick way using python is the following code.&amp;nbsp; You can customize the list of words to be striped from your string.&amp;nbsp; Please do note, this particular rendition is case-sensitive so 'Branch' is not he same as 'branch' and the latter would not be removed. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;string &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Weston Ranch Branch Library"&lt;/SPAN&gt;
stripList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Library'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Branch'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; string&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; stripList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a label expression it would be along the lines of the following and you would replace [string] with the name of your attribute:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="455275" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/455275_Capture.PNG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:19:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/label-class-expression-to-strip-words/m-p/802660#M265</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-12-12T09:19:33Z</dc:date>
    </item>
  </channel>
</rss>

