<?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 Replacing string after a given character but contains a double quote in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142622#M63703</link>
    <description>&lt;P&gt;So this is pretty basic for many of you but I'm a novice when it comes to Python and this one's a doozie.&lt;/P&gt;&lt;P&gt;I concatenated two string fields and now I want to remove all text that I added. I separated them with a semicolon to make it clear where the concatenation occurred between the two field values. The problem is I cannot just use&amp;nbsp;&lt;EM&gt;!Comments!.replace("; SAP Device Info field: WATER 5/8" ULTRASONIC METER", "")&lt;/EM&gt; or some similar function because there are double quotes in the string to indicate inches. I'm making it a rule that we never double quotes for inches again, but this was the data I was given.&lt;/P&gt;&lt;P&gt;Not all fields are the same length, so I can't just trim the last x number of characters across the board either.&lt;/P&gt;&lt;P&gt;I read somewhere that I need a back slash near the double quote or to put the double quote inside of single quotes to exempt if from being recognized as part of the expression, but I can't make it work.&lt;/P&gt;&lt;P&gt;Example below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BenCunningham_0-1644503130849.png" style="width: 605px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33605iF02DDA251C414BB2/image-dimensions/605x143?v=v2" width="605" height="143" role="button" title="BenCunningham_0-1644503130849.png" alt="BenCunningham_0-1644503130849.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Basically, how can I run through this field and get rid of everything after "; SAP Device Info field:"&lt;/P&gt;&lt;P&gt;How can I tell field calculator to trim after the semicolon? Or is there a better way?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Feb 2022 14:35:50 GMT</pubDate>
    <dc:creator>BenCunningham</dc:creator>
    <dc:date>2022-02-10T14:35:50Z</dc:date>
    <item>
      <title>Replacing string after a given character but contains a double quote</title>
      <link>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142622#M63703</link>
      <description>&lt;P&gt;So this is pretty basic for many of you but I'm a novice when it comes to Python and this one's a doozie.&lt;/P&gt;&lt;P&gt;I concatenated two string fields and now I want to remove all text that I added. I separated them with a semicolon to make it clear where the concatenation occurred between the two field values. The problem is I cannot just use&amp;nbsp;&lt;EM&gt;!Comments!.replace("; SAP Device Info field: WATER 5/8" ULTRASONIC METER", "")&lt;/EM&gt; or some similar function because there are double quotes in the string to indicate inches. I'm making it a rule that we never double quotes for inches again, but this was the data I was given.&lt;/P&gt;&lt;P&gt;Not all fields are the same length, so I can't just trim the last x number of characters across the board either.&lt;/P&gt;&lt;P&gt;I read somewhere that I need a back slash near the double quote or to put the double quote inside of single quotes to exempt if from being recognized as part of the expression, but I can't make it work.&lt;/P&gt;&lt;P&gt;Example below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BenCunningham_0-1644503130849.png" style="width: 605px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33605iF02DDA251C414BB2/image-dimensions/605x143?v=v2" width="605" height="143" role="button" title="BenCunningham_0-1644503130849.png" alt="BenCunningham_0-1644503130849.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Basically, how can I run through this field and get rid of everything after "; SAP Device Info field:"&lt;/P&gt;&lt;P&gt;How can I tell field calculator to trim after the semicolon? Or is there a better way?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 14:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142622#M63703</guid>
      <dc:creator>BenCunningham</dc:creator>
      <dc:date>2022-02-10T14:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing string after a given character but contains a double quote</title>
      <link>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142646#M63704</link>
      <description>&lt;P&gt;What if you use single quote instead.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;!Comments!.replace('; SAP Device Info field: WATER 5/8" ULTRASONIC METER', '')&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 10 Feb 2022 15:31:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142646#M63704</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2022-02-10T15:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing string after a given character but contains a double quote</title>
      <link>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142684#M63707</link>
      <description>&lt;P&gt;You can also split at the colon, then take the part before the split.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;test1 = "juice:maps"    # input
test2 = test1.split(":")# split at the colon. yields ["juice", [maps"] 
test3 = test2[0]        # grab the first item in the list. "juice"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:17:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-string-after-a-given-character-but/m-p/1142684#M63707</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2022-02-10T16:17:36Z</dc:date>
    </item>
  </channel>
</rss>

