<?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: Add a hyphen before the last 3 characters of variable length string in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592685#M33493</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;VBSCRIPT:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dim a as string 
a = "MyFavoriteString123" 
a = Left(a, Len(a) - 3) &amp;amp; "-" &amp;amp; Right(a, 3)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:27:01 GMT</pubDate>
    <dc:creator>TedKowal</dc:creator>
    <dc:date>2021-12-12T01:27:01Z</dc:date>
    <item>
      <title>Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592679#M33487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All. I'm looking for some VBScript help (or Python) to add a hyphen before the last 3 characters of variable length string. I can manage with fixed length strings, but not variable ones. 12345 = 12-345 and 123456 = 123-456.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Luke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592679#M33487</guid>
      <dc:creator>LukeSnyder</dc:creator>
      <dc:date>2015-04-24T12:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592680#M33488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No matter the language, the task is the same:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Compute string length&lt;/LI&gt;&lt;LI&gt;Create new string composed of:&lt;OL&gt;&lt;LI&gt;substring(pos 1 to (len-3))&lt;/LI&gt;&lt;LI&gt;hyphen&lt;/LI&gt;&lt;LI&gt;substring(pos len-2 to len)&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax is different in each language, as well as the radix of the first character (0 or 1) and the exact invocation of the substring function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:41:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592680#M33488</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2015-04-24T12:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592681#M33489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;got to love slicing&amp;nbsp; (EDIT&amp;nbsp; oooops Sorry Vince ... was playing and didn't see you had posted already)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = '123456'
&amp;gt;&amp;gt;&amp;gt; out = a[:len(a)-3]+'-'+a[len(a)-3:]
&amp;gt;&amp;gt;&amp;gt; out
'123-456'
&amp;gt;&amp;gt;&amp;gt; a = '12345'
&amp;gt;&amp;gt;&amp;gt; out = a[:len(a)-3]+'-'+a[len(a)-3:]
&amp;gt;&amp;gt;&amp;gt; out
'12-345'
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592681#M33489</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T01:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592682#M33490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No worries.&amp;nbsp; I often work with larger strings, which are O(N) in the length function, so I usually capture length once, vice embeding it twice. Yes, an optimizer might pick that up, but I like to pitch softly at optimizers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 13:08:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592682#M33490</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2015-04-24T13:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592683#M33491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 13:09:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592683#M33491</guid>
      <dc:creator>LukeSnyder</dc:creator>
      <dc:date>2015-04-24T13:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592684#M33492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't forget to mark the post with the correct answer as correct &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 13:11:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592684#M33492</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-04-24T13:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592685#M33493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;VBSCRIPT:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dim a as string 
a = "MyFavoriteString123" 
a = Left(a, Len(a) - 3) &amp;amp; "-" &amp;amp; Right(a, 3)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:27:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592685#M33493</guid>
      <dc:creator>TedKowal</dc:creator>
      <dc:date>2021-12-12T01:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add a hyphen before the last 3 characters of variable length string</title>
      <link>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592686#M33494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ted. I'm still learning...and always will be of course. I like this approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 14:26:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/add-a-hyphen-before-the-last-3-characters-of/m-p/592686#M33494</guid>
      <dc:creator>LukeSnyder</dc:creator>
      <dc:date>2015-04-24T14:26:26Z</dc:date>
    </item>
  </channel>
</rss>

