<?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: Use Regex to Replace Spaces In a Table Column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Use-Regex-to-Replace-Spaces-In-a-Table-Column/m-p/836776#M101366</link>
    <description>&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.1/#page/jmp/character-functions-2.shtml?os=win&amp;amp;source=application#ww3866713" target="_self"&gt;Collapse Whitespace()&lt;/A&gt; is basically meant for this (you can also use other methods)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

mystr = "a         b";

res1 = Regex(mystr, " +", " ", GLOBALREPLACE);

res2 = Concat Items(Words(mystr, " "), " ");

res3 = Collapse Whitespace(mystr);

show(res1, res2, res3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Recode has Collapse Whitespace so you can just use that&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1738865998371.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72560iA2A97457CF76543D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1738865998371.png" alt="jthi_0-1738865998371.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and it will provide you with a script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Recode column: Column 6
Local({dt},
	dt = Data Table("Big Class");
	dt &amp;lt;&amp;lt; Begin Data Update;
	For Each Row(dt, dt:Column 6[] = Collapse Whitespace(dt:Column 6));
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2025 18:20:46 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-02-06T18:20:46Z</dc:date>
    <item>
      <title>Use Regex to Replace Spaces In a Table Column</title>
      <link>https://community.jmp.com/t5/Discussions/Use-Regex-to-Replace-Spaces-In-a-Table-Column/m-p/836764#M101365</link>
      <description>&lt;P&gt;I have a table column that contains a variable quantity of spaces in each cell.&amp;nbsp; I want to collapse those to a single space.&amp;nbsp; I presume regex can eliminate those but I've never applied regex outside a column formula.&amp;nbsp; Is this even the best approach and if so, how do I achieve it?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 18:04:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-Regex-to-Replace-Spaces-In-a-Table-Column/m-p/836764#M101365</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2025-02-06T18:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use Regex to Replace Spaces In a Table Column</title>
      <link>https://community.jmp.com/t5/Discussions/Use-Regex-to-Replace-Spaces-In-a-Table-Column/m-p/836776#M101366</link>
      <description>&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.1/#page/jmp/character-functions-2.shtml?os=win&amp;amp;source=application#ww3866713" target="_self"&gt;Collapse Whitespace()&lt;/A&gt; is basically meant for this (you can also use other methods)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

mystr = "a         b";

res1 = Regex(mystr, " +", " ", GLOBALREPLACE);

res2 = Concat Items(Words(mystr, " "), " ");

res3 = Collapse Whitespace(mystr);

show(res1, res2, res3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Recode has Collapse Whitespace so you can just use that&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1738865998371.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72560iA2A97457CF76543D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1738865998371.png" alt="jthi_0-1738865998371.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and it will provide you with a script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Recode column: Column 6
Local({dt},
	dt = Data Table("Big Class");
	dt &amp;lt;&amp;lt; Begin Data Update;
	For Each Row(dt, dt:Column 6[] = Collapse Whitespace(dt:Column 6));
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 18:20:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-Regex-to-Replace-Spaces-In-a-Table-Column/m-p/836776#M101366</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-06T18:20:46Z</dc:date>
    </item>
  </channel>
</rss>

