<?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: Simple Regex refuses to work in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359283#M76200</link>
    <description>&lt;P&gt;Yes, both are Text Fields that's helpful though. Thought I was going crazy.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 18:54:29 GMT</pubDate>
    <dc:creator>ccowin_odfw</dc:creator>
    <dc:date>2023-12-11T18:54:29Z</dc:date>
    <item>
      <title>Simple Regex refuses to work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359266#M76196</link>
      <description>&lt;P&gt;So I have addresses that have a zip in one field, and I want to extract the zip to a new field. Literally, the simplest regex that you can do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine in Python and returns 97321:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import re

address = '97321'
postal_code = re.search(r'.*(\d{5}(\-\d{4})?)$', address)
print(postal_code.group())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Pro, in Calculate Field it acts like postal_code is None every single time, but I dont know because there is no way to properly debug this so I have no idea what is wrong. So please tell me what the secret trick is to get regex to work like it is supposed to in every other piece of software on earth.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 18:36:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359266#M76196</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-12-11T18:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Regex refuses to work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359271#M76198</link>
      <description>&lt;P&gt;Dumb question, but are they both text fields?&lt;/P&gt;&lt;P&gt;It worked fine for me when both were text.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1702320367363.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88660iE4538A4D7C6C764C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1702320367363.png" alt="AlfredBaldenweck_0-1702320367363.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 18:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359271#M76198</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-11T18:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Regex refuses to work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359283#M76200</link>
      <description>&lt;P&gt;Yes, both are Text Fields that's helpful though. Thought I was going crazy.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 18:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359283#M76200</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-12-11T18:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Regex refuses to work</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359295#M76202</link>
      <description>&lt;P&gt;It doesn't like it when you have text after the zip.&lt;/P&gt;&lt;P&gt;So, any spaces, any letters, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fixed it in my test data by getting rid of the $.&lt;/P&gt;&lt;P&gt;I also got rid of the .*, since it ends up grabbing any text in front.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def extract(address):
    import re
    postal_code = re.search(r'(\d{5}(\-\d{4})?)', address).group(0)
    return postal_code&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1702321618828.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88667i4A2498DE56F56072/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1702321618828.png" alt="AlfredBaldenweck_0-1702321618828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 19:07:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/simple-regex-refuses-to-work/m-p/1359295#M76202</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-11T19:07:40Z</dc:date>
    </item>
  </channel>
</rss>

