<?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 - regular expressions in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636873#M21231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;enclose within strip&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV style="display: block;"&gt;&lt;DIV&gt;&lt;DIV data-linkedid="communications_2_717517_14_2087" style="display: block;"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV data-thread-id="202419" data-thread-type="1"&gt;&lt;DIV data-current="" data-extendedauthors="false" data-extvisible="false" data-objectid="717572" data-objecttype="2" data-thread-id="202419"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;(!YourField!.split('-')[4]).strip()&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Sep 2017 14:46:40 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2017-09-25T14:46:40Z</dc:date>
    <item>
      <title>Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636869#M21227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;I'm beginner in ArcGIS Pro (I just switched from QGIS) and have some problem with some a little more advanced operation in field calculator. I would like to know how to use REGEX in field calculator to extract particular part of the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The string if in "Adr_for" field and in field "Number" I want to have extracted part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples of the strings in "Adr_for":&lt;BR /&gt;13-0222222-1-02226-249A - -&lt;BR /&gt;13-022222-1-02225-33 - -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expected result in "Number":&lt;BR /&gt;249A&lt;BR /&gt;33&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regex expression (which worked in QGIS):&lt;BR /&gt;((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to use something like this in ArcGIS PRO field calculator but it didn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;BR /&gt;regex(!Adr_for!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Block:&lt;BR /&gt;import re&lt;BR /&gt;def regex(Adr_for):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return re.search(r"""((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))""", Adr_for)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I do this to achieve expected result?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 10:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636869#M21227</guid>
      <dc:creator>MichalJurewicz</dc:creator>
      <dc:date>2017-09-25T10:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636870#M21228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I presume your example is conincidently too simple to expect&lt;/P&gt;&lt;P&gt;!YourField!.split('-')[4]&lt;/P&gt;&lt;P&gt;to work then?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 11:57:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636870#M21228</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-09-25T11:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636871#M21229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's very nice solution but not perfect. It leaves empty spaces in field after values '33 ' and '249A ' (because between value and '-' there is space). I know I can fix it with some other basic function by second calculation pass but I would like to achieve that with one pass using regex, because it's something I used very often in QGIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW Is there any documents with description of all basic functions (like .split) of Field Calculator?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:24:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636871#M21229</guid>
      <dc:creator>MichalJurewicz</dc:creator>
      <dc:date>2017-09-25T12:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636872#M21230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the doc. on a few examples of Calculate Field, you could check&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm"&gt;Calculate Field examples—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:45:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636872#M21230</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2017-09-25T12:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636873#M21231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;enclose within strip&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV style="display: block;"&gt;&lt;DIV&gt;&lt;DIV data-linkedid="communications_2_717517_14_2087" style="display: block;"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV data-thread-id="202419" data-thread-type="1"&gt;&lt;DIV data-current="" data-extendedauthors="false" data-extvisible="false" data-objectid="717572" data-objecttype="2" data-thread-id="202419"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;(!YourField!.split('-')[4]).strip()&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 14:46:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636873#M21231</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-09-25T14:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculator - regular expressions</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636874#M21232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will work, I suspect all the raw string triple quoting is doing something, just in the Python window all is good:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import re&lt;BR /&gt;p = re.compile('((\d+(?!(\d|-))\w)|(\d+(?!(\d|-))))')&lt;BR /&gt;Adr_for = '13-0222222-1-02226-249A - -'&lt;BR /&gt;re.search(p,Adr_for)&lt;BR /&gt;&amp;lt;_sre.SRE_Match object; span=(19, 23), match=&lt;STRONG&gt;'249A&lt;/STRONG&gt;'&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 14:49:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-regular-expressions/m-p/636874#M21232</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2017-09-25T14:49:13Z</dc:date>
    </item>
  </channel>
</rss>

