<?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: Delete text substring from longer text in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320085#M18316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are there a lot of different substrings you want to replace? I'm thinking maybe you could use a Python dictionary, but that would require explicit definition of substrings and their replacements. Since the substrings aren't always replaced with the same text, you'd also have to have some sort of decision-making in the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Apr 2019 22:44:06 GMT</pubDate>
    <dc:creator>StephenM</dc:creator>
    <dc:date>2019-04-03T22:44:06Z</dc:date>
    <item>
      <title>Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320082#M18313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a field in a .dbf file with a long text string.&amp;nbsp;&amp;nbsp; I need to delete x amount of characters WITHIN the text string.&amp;nbsp;&amp;nbsp;&amp;nbsp; I am also not very good with programming so I haven't looked into creating a script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially I have this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aaa bbb ccc ddd eee fff ggg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aaa bbb ccc fff ggg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attaching the .dbf in MS Excel format (.xls).&amp;nbsp;&amp;nbsp; I have had some luck with functions in MS Excel but I can't get the consistency I need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2019 23:32:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320082#M18313</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-02T23:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320083#M18314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The REPLACE function might work for this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://exceljet.net/formula/remove-text-by-position"&gt;Excel formula: Remove text by position&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6;" width="100%"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef;"&gt;&lt;TH style="width: 38.5141%;"&gt;Original text&lt;/TH&gt;&lt;TH style="width: 16.4859%;"&gt;Formula&lt;/TH&gt;&lt;TH style="width: 36%;"&gt;New text&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="width: 38.5141%;"&gt;NAP NAP 012.039 DH 00.449 LINCOLN AVE OC 21-89&lt;/TD&gt;&lt;TD style="width: 16.4859%;"&gt;=REPLACE(A1,4,12,"")&lt;/TD&gt;&lt;TD style="width: 36%;"&gt;NAP DH 00.449 LINCOLN AVE OC 21-89&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 19:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320083#M18314</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2019-04-03T19:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320084#M18315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stephen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your efforts but I have been married to MS Excel for the last 4 days!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main reason I was posting on the ArcGIS Forum is that I wanted to hope beyond all hope that maybe there is a VBA or Python script out there that would do what I’m trying to do in MS Excel?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sheet 2 of Naplables0403 is closer to what I am wanting.  I can do nested SUBSTITUTE functions to replace the text strings but I can’t get one set of SUBSTITUTE functions to repeat because somehow its text-string specific.   i.e., DH 00.334 can only be deleted from the first text string, but even if I put an instance number of 2 (where I’m hoping the second string can be replaced), it doesn’t do that—it only replaces the text its referring to!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps a better way of putting this is how can I replace substrings of text of varying lengths with spaces between varying locations of spaces??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aaa bbb ccc ddd eee fff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would result in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aaa bbb eee fff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AAA BBB CCC DD EEE FF GGG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could result in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AAA BBB CCC  FF GG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel T. Brenner&lt;/P&gt;&lt;P&gt;RESEARCH ANALYST I (GEOGRAPHIC INFORMATION SYSTEMS)&lt;/P&gt;&lt;P&gt;DIVISION OF RESEARCH, INNOVATION, and SYSTEM INFORMATION&lt;/P&gt;&lt;P&gt;Highway System Information and Performance&lt;/P&gt;&lt;P&gt;1120 N Street MS 38&lt;/P&gt;&lt;P&gt;Sacramento, CA  95814&lt;/P&gt;&lt;P&gt;(916) 657-4277&lt;/P&gt;&lt;P&gt;(510) 593-7547 cell&lt;/P&gt;&lt;P&gt;daniel.brenner@dot.ca.gov&amp;lt;mailto:daniel.brenner@dot.ca.gov&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;“Consider the unconsidered.”&lt;/P&gt;&lt;P&gt;“Certainty is not a sure thing!”&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 20:10:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320084#M18315</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-03T20:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320085#M18316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are there a lot of different substrings you want to replace? I'm thinking maybe you could use a Python dictionary, but that would require explicit definition of substrings and their replacements. Since the substrings aren't always replaced with the same text, you'd also have to have some sort of decision-making in the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 22:44:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320085#M18316</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2019-04-03T22:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320086#M18317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes there are a lot of different values I need to replace of varying lengths (see the parts of the text strings beginning with ‘DH’ or the one with ‘E DH’….)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven’t worked with Python Dictionaries.  Could you give me an example of what you are talking about?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 22:56:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320086#M18317</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-03T22:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320087#M18318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://www.w3schools.com/python/python_dictionaries.asp" rel="nofollow noopener noreferrer" target="_blank"&gt;Dictionaries&lt;/A&gt; are collections of key:value pairs, for example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;d = {"NAP NAP R": "NAP-029-R", "DH 00.334": ""}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Using this dictionary, &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;d["&lt;SPAN&gt;NAP NAP R&lt;/SPAN&gt;"]&lt;/SPAN&gt; would give you the value &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"NAP-029-R"&lt;/SPAN&gt;, and &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;d["00.334"]&lt;/SPAN&gt; would give you an empty string. Using a dictionary you could loop through the rows and do &lt;A href="https://www.w3schools.com/python/ref_string_replace.asp" rel="nofollow noopener noreferrer" target="_blank"&gt;replaces&lt;/A&gt;&amp;nbsp;based on dictionary values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the field calculator in ArcGIS Pro, for example:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="table showing original strings and strings after replacement" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/441205_replace_substrings.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&amp;nbsp;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;mod = mod_substr(!orig!)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; re

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;mod_substr&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;orig&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    d &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NAP NAP R"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NAP-029-R"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
         &lt;SPAN class="string token"&gt;"DH 00.334"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
         &lt;SPAN class="string token"&gt;"NAP NAP 0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NAP-121-0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
         &lt;SPAN class="string token"&gt;"NAP YNTV 0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NAP-121-0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
         &lt;SPAN class="string token"&gt;"NAP R 006"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NAP-121-R 006"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    tmp_str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; orig

    &lt;SPAN class="comment token"&gt;# Replace substrings if they exist as a key in the dictionary&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; key &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;keys&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&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; key &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; tmp_str&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            tmp_str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; tmp_str&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;key&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;key&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;# Remove duplicate spaces&lt;/SPAN&gt;
    tmp_str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sub&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' +'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; tmp_str&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; tmp_str&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;May not be feasible though, since you'd have to define each substring and its replacement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:12:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320087#M18318</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2021-12-11T15:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320088#M18319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stephen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks big time for this; this stuff is huge but I will do what I can to follow through on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But yes, your last line does get at one of the issues that Excel does much better on.    That was one of (if not THE) core issues, was that what would have represented X number of characters at varying lengths and varying places in a text string.   Like you’re saying, to have to put in each one of the text strings that I wanted to conver would be kind of bulky.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But at the same time some of what you’re doing is what I came up with in terms of character substrings and how to replace them—See attached!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My last questions to you are how did you learn this and where did you get the opportunity to do so?   Was it on the job or in a class?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again and again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel T. Brenner&lt;/P&gt;&lt;P&gt;RESEARCH ANALYST I (GEOGRAPHIC INFORMATION SYSTEMS)&lt;/P&gt;&lt;P&gt;DIVISION OF RESEARCH, INNOVATION, and SYSTEM INFORMATION&lt;/P&gt;&lt;P&gt;Highway System Information and Performance&lt;/P&gt;&lt;P&gt;1120 N Street MS 38&lt;/P&gt;&lt;P&gt;Sacramento, CA  95814&lt;/P&gt;&lt;P&gt;(916) 657-4277&lt;/P&gt;&lt;P&gt;(510) 593-7547 cell&lt;/P&gt;&lt;P&gt;daniel.brenner@dot.ca.gov&amp;lt;mailto:daniel.brenner@dot.ca.gov&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;“Consider the unconsidered.”&lt;/P&gt;&lt;P&gt;“Certainty is not a sure thing!”&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Apr 2019 21:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320088#M18319</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-04T21:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320089#M18320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand what criteria/condition is driving the replacement text.&amp;nbsp; For example, when&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;NAP NAP R 004.501 DH 00.334 VIA IMOLA AVE
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gets changed to&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;NAP-121-R 004.501 DH 00.334 VIA IMOLA AVE
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;, " NAP " is getting changed to "-121-" .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;NAP NAP 010.698 DH 00.501 OLD SONOMA RD OC 21 87
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gets changed to&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;NAP-029-010.698  OLD SONOMA RD OC 21 87
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;, " NAP " is getting changed to "-029-".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How are you deciding when " NAP " gets changed to one value versus another?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:12:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320089#M18320</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T15:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320090#M18321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its based on how the original text string describes a point location on a certain highway number network (like those little sticks along the side of the highway that have County-Route-Postmile stenciled on them) that’s in another field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did discuss the same matter with another respondent from a different forum and he was saying that the text strings couldn’t be created with out a logical scenario (IF location = x then label with Y) and I thought of using a drop down list of all the routes, and even joining them by another attribute, but all of that was going to be too much and given that I was going to be using the points layer’s dbf file in MS Excel I was going to be able to see the route number for the point location that needed the text string I’m trying to create and so it was just a matter of substituting when I had to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Someone else emailed about using Data Dictionaries and I saw how they essentially did the same thing but the advantage for MS Excel is that I wouldn’t have had to include every record’s substring as part of one of them, and that the code to use was way simpler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel T. Brenner&lt;/P&gt;&lt;P&gt;RESEARCH ANALYST I (GEOGRAPHIC INFORMATION SYSTEMS)&lt;/P&gt;&lt;P&gt;DIVISION OF RESEARCH, INNOVATION, and SYSTEM INFORMATION&lt;/P&gt;&lt;P&gt;Highway System Information and Performance&lt;/P&gt;&lt;P&gt;1120 N Street MS 38&lt;/P&gt;&lt;P&gt;Sacramento, CA  95814&lt;/P&gt;&lt;P&gt;(916) 657-4277&lt;/P&gt;&lt;P&gt;(510) 593-7547 cell&lt;/P&gt;&lt;P&gt;daniel.brenner@dot.ca.gov&amp;lt;mailto:daniel.brenner@dot.ca.gov&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;“Consider the unconsidered.”&lt;/P&gt;&lt;P&gt;“Certainty is not a sure thing!”&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Apr 2019 23:31:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320090#M18321</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-04T23:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320091#M18322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking at that attachment, &lt;A href="https://www.w3schools.com/python/python_regex.asp"&gt;regular expressions&lt;/A&gt;&amp;nbsp;might be useful. If you're looking to get rid of all text matching the pattern "DH ##.###", for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="example of regular expressions in Python" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/441244_python_regex.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I know of Python has been self-taught, but I did have a baseline established from studying other programming languages. I took a handful of programming classes in college, then started tinkering with Python when I was studying GIS. I've been able to continue tinkering in my job, using it to automate processes and try to solve problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2019 00:02:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320091#M18322</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2019-04-05T00:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320092#M18323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lucky you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve been married to MS Excel and watch my GIS career gently weep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More soon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2019 00:09:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320092#M18323</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-05T00:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320093#M18324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with the other respondent from the different forum.&amp;nbsp; The crux of your automation/scripting problem lies in:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Edited the "NAP" text string as need be to represent the correct character string (or spaces) as need be&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You know what is correct "as need be," but you don't seem to be able to write out a rule set for it.&amp;nbsp; If you are changing your script/formula every few rows, and not relying on a per-defined rule set of what needs to get changed to what, then you might as well just do it by hand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2019 12:19:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320093#M18324</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-04-05T12:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320094#M18325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached and also refer to the other stuff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The deal is is that NAP ‘xxx’ can a 3-4 letter character string or a space between spaces.   It’s the variability of what needs to be changed to the even bigger variability in terms of the number of text strings that could go in front of the space between the 3 -4 character string or the space AND the R or L or other space before a 6 digit string representing a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did come up with a partial solution, where I created a text string in MS Excel with a dash before and after the route number; this text string would replace the 2nd set of characters, but again, the variability of the size of the string is a kicker.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does any of what you guys are suggesting deal with this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it would cover for some of what the bigger formula was getting at with the “ -121- “ part, but again, not one string fits all.   I even had to edit 29 to become 029 because it wasn’t in a consistent 3 digit format like the other route.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second string is nearly out the window in terms of variability of starting position and numbers of characters.    But again, I didn’t have a problem editing the characters and the text strings as need be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seriously I do thank you for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel T. Brenner&lt;/P&gt;&lt;P&gt;RESEARCH ANALYST I (GEOGRAPHIC INFORMATION SYSTEMS)&lt;/P&gt;&lt;P&gt;DIVISION OF RESEARCH, INNOVATION, and SYSTEM INFORMATION&lt;/P&gt;&lt;P&gt;Highway System Information and Performance&lt;/P&gt;&lt;P&gt;1120 N Street MS 38&lt;/P&gt;&lt;P&gt;Sacramento, CA  95814&lt;/P&gt;&lt;P&gt;(916) 657-4277&lt;/P&gt;&lt;P&gt;(510) 593-7547 cell&lt;/P&gt;&lt;P&gt;daniel.brenner@dot.ca.gov&amp;lt;mailto:daniel.brenner@dot.ca.gov&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;“Consider the unconsidered.”&lt;/P&gt;&lt;P&gt;“Certainty is not a sure thing!”&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2019 19:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320094#M18325</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-05T19:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320095#M18326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you could use regular expressions to replace substrings based on the character index of the first number in the ###.### sequence. Get the index of that character, then&amp;nbsp;use string slices to replace all text between the third character (assuming all the rows start with "NAP") and that index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example in ArcGIS Pro using Python:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;replace_substr&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;s&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rte&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; re

    &lt;SPAN class="comment token"&gt;# Set pattern to replace beginning section. Optional&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# L or R and a space, then 3 numbers, a period, three&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# numbers, a space, 1 or 2 letters, and a space.&lt;/SPAN&gt;
    ptn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;compile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"([LR] )?[0-9]{3}.[0-9]{3} [A-Z]{1,2} "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Match the pattern in the string&lt;/SPAN&gt;
    match &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;finditer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ptn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Get the first match&lt;/SPAN&gt;
    m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;match&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Get the index where the match started&lt;/SPAN&gt;
    idx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; m&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;start&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Create new string by concatenating string slices and route&lt;/SPAN&gt;
    new_str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rte &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;idx&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Set pattern to replace the 'DH ##.###' section&lt;/SPAN&gt;
    ptn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;compile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"DH [0-9]{2}.[0-9]{3}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="comment token"&gt;# Replace the 'DH ##.###' section with nothing&lt;/SPAN&gt;
    new_str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sub&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;" +"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; re&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sub&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ptn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_str&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; new_str‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;&lt;IMG __jive_id="441483" alt="table showing original strings and strings after replacement using regular expressions" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/441483_replace_substrings_regex.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:12:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320095#M18326</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2021-12-11T15:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text substring from longer text</title>
      <link>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320096#M18327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wouldn’t say that solves the issue because it feels like too much and I haven’t tried it out either; although I have gotten a few things to work, just had to do some editing in Excel to  do so.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2019 21:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/delete-text-substring-from-longer-text/m-p/320096#M18327</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2019-04-08T21:26:33Z</dc:date>
    </item>
  </channel>
</rss>

