<?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: Can Substitute implement the function of regular substitution? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709968#M89387</link>
    <description>&lt;P&gt;Below are few different options what you could do (if the case is always like those examples, I would most likely use Word)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

my_str ="Col2[20231219]";

str1 = Word(1, my_str, "[");
str2 = Regex(my_str, "\[^(.+)\[]\", "\1");
str3 = Left(my_str, 4);
str4 = Substr(my_str, 1, Contains(my_str, "[") - 1);

Show(str1, str2, str3, str4);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 17 Dec 2023 13:09:37 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-12-17T13:09:37Z</dc:date>
    <item>
      <title>Can Substitute implement the function of regular substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709941#M89382</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;For example, replace the column name [20231216] to show that this 20231216 is a variable 8-digit number:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Col1[20231216]、Col2[20231219]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 2, i &amp;lt;= N Col( dt ), i++,
	ca = Column( i ) &amp;lt;&amp;lt; Get Name;
	cc = Substitute( ca, "[(.{8,})]", "" );//？？
	Column( dt, i ) &amp;lt;&amp;lt; set name( cc );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2023 12:18:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709941#M89382</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-12-17T12:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can Substitute implement the function of regular substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709946#M89383</link>
      <description>&lt;P&gt;If you want to just remove [] from your string you can provide multiple values for Substitute for example in a list&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

my_str = "[20231216]";
my_new_str = Substitute(my_str, {"[", "]"}, ""); //"20231216"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or you could use regex with something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex(my_str, "\[\[(.*)\]]\", "\1"); // "20231216"&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;Regex can also be used to replacements if needed&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex(my_str, "\[\[|\]]\", "", GLOBALREPLACE); // "20231216"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Dec 2023 12:42:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709946#M89383</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-17T12:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can Substitute implement the function of regular substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709952#M89385</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;I need to get rid of the eight numbers.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col1[20231216] → Col1
Col2[20231219] → Col2&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Dec 2023 12:42:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709952#M89385</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-12-17T12:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can Substitute implement the function of regular substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709968#M89387</link>
      <description>&lt;P&gt;Below are few different options what you could do (if the case is always like those examples, I would most likely use Word)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

my_str ="Col2[20231219]";

str1 = Word(1, my_str, "[");
str2 = Regex(my_str, "\[^(.+)\[]\", "\1");
str3 = Left(my_str, 4);
str4 = Substr(my_str, 1, Contains(my_str, "[") - 1);

Show(str1, str2, str3, str4);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Dec 2023 13:09:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-Substitute-implement-the-function-of-regular-substitution/m-p/709968#M89387</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-17T13:09:37Z</dc:date>
    </item>
  </channel>
</rss>

