<?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: Field calculator to extract string in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576745#M92069</link>
    <description>&lt;LI-CODE lang="python"&gt;a = 'ABCDEFG_(0.2014HA)'
b = 'ABCDEFG (TESTXX) (123HA)'

a[a.find("("):].split(" ")[-1][1:-1]
'0.2014HA'
b[b.find("("):].split(" ")[-1][1:-1]
'123HA'

# ---- yielding a code block for your 'fld'

def splitter(fld):
    """Split on a unique case"""
    val = fld[fld.find("("):].split(" ")[-1][1:-1]
    return val
    

splitter(a)
'0.2014HA'

splitter(b)
'123HA'&lt;/LI-CODE&gt;&lt;P&gt;morning brain refresher&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jan 2025 11:27:18 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2025-01-17T11:27:18Z</dc:date>
    <item>
      <title>Field calculator to extract string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576743#M92068</link>
      <description>&lt;P&gt;Hi all, I am trying to get field calculator to help me extract a string from a field and calculate in another field.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Name&lt;/TD&gt;&lt;TD width="50%"&gt;Info&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCDEFG_(0.2014HA)&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;!Place!.split('(')[1].split(')')[0]&amp;nbsp;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCDEFG (TESTXX) (123HA)&lt;/TD&gt;&lt;TD&gt;??&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the first field the calculation will get me the value in brackets so I end up with 0.2014HA which is great.&lt;/P&gt;&lt;P&gt;How would I do it for the second one? I want to extract only what is in the second bracket and ignore the first one&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 10:59:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576743#M92068</guid>
      <dc:creator>ALBJORGUI</dc:creator>
      <dc:date>2025-01-17T10:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator to extract string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576745#M92069</link>
      <description>&lt;LI-CODE lang="python"&gt;a = 'ABCDEFG_(0.2014HA)'
b = 'ABCDEFG (TESTXX) (123HA)'

a[a.find("("):].split(" ")[-1][1:-1]
'0.2014HA'
b[b.find("("):].split(" ")[-1][1:-1]
'123HA'

# ---- yielding a code block for your 'fld'

def splitter(fld):
    """Split on a unique case"""
    val = fld[fld.find("("):].split(" ")[-1][1:-1]
    return val
    

splitter(a)
'0.2014HA'

splitter(b)
'123HA'&lt;/LI-CODE&gt;&lt;P&gt;morning brain refresher&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 11:27:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576745#M92069</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-01-17T11:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator to extract string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576746#M92070</link>
      <description>&lt;P&gt;I found another way of doing it too.&lt;/P&gt;&lt;P&gt;!Name!.split('(')[2].split(')')[0]&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 11:38:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576746#M92070</guid>
      <dc:creator>ALBJORGUI</dc:creator>
      <dc:date>2025-01-17T11:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator to extract string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576789#M92075</link>
      <description>&lt;P&gt;True, but yours fails for the first case&lt;/P&gt;&lt;LI-CODE lang="python"&gt;a.split('(')[2].split(')')[0]
Traceback (most recent call last):

  Cell In[3], line 1
    a.split('(')[2].split(')')[0]

IndexError: list index out of range


b.split('(')[2].split(')')[0]
 '123HA'&lt;/LI-CODE&gt;&lt;P&gt;where as the function in my example works for both&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 15:12:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/field-calculator-to-extract-string/m-p/1576789#M92075</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-01-17T15:12:51Z</dc:date>
    </item>
  </channel>
</rss>

