<?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: How do I use Regex substitution? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595780#M79954</link>
    <description>&lt;P&gt;This is an example for negative look behind and positive look ahead, &lt;A href="https://www.regular-expressions.info/lookaround.html" target="_blank" rel="noopener"&gt;lookaround&lt;/A&gt;. Step 3 is using both.&lt;/P&gt;
&lt;PRE&gt;(?&amp;lt;!\d)&lt;/PRE&gt;
&lt;P&gt;matches a single character that is &lt;EM&gt;not&lt;/EM&gt; a digit just &lt;EM&gt;before&lt;/EM&gt; the current zero-length position.&lt;/P&gt;
&lt;PRE&gt;(?=\d)&lt;/PRE&gt;
&lt;P&gt;matches a single character that &lt;EM&gt;is&lt;/EM&gt; a digit just &lt;EM&gt;after&lt;/EM&gt; the current zero-length position.&lt;/P&gt;
&lt;P&gt;The tab character is inserted into the zero-length position to separate the non-digit from the digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt = "d试1(-是2^3([a]文/字789(+内\c容4$3";
// change paren to newline...
step1 = Regex( txt, "\(", "\!n", globalreplace );
// remove unwanted characters - + / \ ^ $ [ ] a..z A..Z
step2 = Regex( step1, "[-+/\\^$[\]a-zA-Z]", "", globalreplace );
// insert tab when character before is not a digit and character after is a digit
step3 = Regex( step2, "(?&amp;lt;!\d)(?=\d)", "\!t", globalreplace );
// add header
step4 = "aaa\!tbbb\!n" || step3;
// import the string without making a file on disk
Open( Char To Blob( step4 ), "text" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tabs separate fields" style="width: 222px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49689i961EE5E9BA544965/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="tabs separate fields" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;tabs separate fields&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 12:03:48 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2023-02-01T12:03:48Z</dc:date>
    <item>
      <title>How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595432#M79919</link>
      <description>&lt;P&gt;Replaces the specified "(" with a newline character and removes all non-Chinese and non-numeric characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;d试1(-是23(a文字789(+内c容4$3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-01-31_20-13-35.png" style="width: 161px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49669iDC716C5249468CDF/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-01-31_20-13-35.png" alt="2023-01-31_20-13-35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt="d试1(-是23(a文字789(+内c容4$3";

na=Regex(txt,  ？？ );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;CODE class=" language-jsl"&gt;Thanks!&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:39:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595432#M79919</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-06-08T16:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595485#M79920</link>
      <description>&lt;P&gt;use two statements. I added some extra problem characters to your example...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt = "d试1(-是2^3([a]文/字789(+内\c容4$3";
step1 = Regex( txt, "\(", "\!n", globalreplace );
step2 = Regex( step1, "[-+/\\^$[\]a-zA-Z]", "", globalreplace );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;The ( needs to be regex-escaped for step1. The newline is JSL-escaped.&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;For step2, the syntax of the [...] is complicated:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;start with the - because without a leading character it can't be a range like a-z. (Otherwise it needs a regex-escape, \- )&lt;/LI&gt;
&lt;LI&gt;the \ needs to be regex-escaped&lt;/LI&gt;
&lt;LI&gt;the ] needs to be regex-escaped&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Be careful not to accidentally write the JSL-escape \[ which changes the way JSL interprets strings. This is likely to happen when working with character sets in [...] if you don't know it will be a problem.&lt;/P&gt;
&lt;P&gt;Notice the sequence [\]. It is not a character set.&amp;nbsp; It is 2 characters that are in a character set.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 14:58:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595485#M79920</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-01-31T14:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595650#M79936</link>
      <description>&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'll just use EmEditor to re replace&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 23:46:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595650#M79936</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-01-31T23:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595747#M79952</link>
      <description>&lt;P&gt;&lt;BR /&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to take this re substitution one step further: insert tabs between the Chinese characters and the data (set the Chinese characters in the original text to the left and the numbers to the right), to achieve a table that can input the result of the substitution directly into the JMP:&lt;BR /&gt;How do you need to change the code?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-02-01_17-58-10.png" style="width: 158px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49688i14C07D3E234FDDFE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-02-01_17-58-10.png" alt="2023-02-01_17-58-10.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt = "d试1(-是2^3([a]文/字789(+内\c容4$3";
step1 = Regex( txt, "\(", "\!n", globalreplace );//？？
step2 = Regex( step1, "[-+/\\^$[\]a-zA-Z]", "", globalreplace );//？？

s = N Items( step2 );
dt = New Table( "A", Add Rows( s ), New Column( "txt", Character, "Nominal" ), New Column( "num" ) );
dt[0, 0] = step2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 10:14:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595747#M79952</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T10:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595780#M79954</link>
      <description>&lt;P&gt;This is an example for negative look behind and positive look ahead, &lt;A href="https://www.regular-expressions.info/lookaround.html" target="_blank" rel="noopener"&gt;lookaround&lt;/A&gt;. Step 3 is using both.&lt;/P&gt;
&lt;PRE&gt;(?&amp;lt;!\d)&lt;/PRE&gt;
&lt;P&gt;matches a single character that is &lt;EM&gt;not&lt;/EM&gt; a digit just &lt;EM&gt;before&lt;/EM&gt; the current zero-length position.&lt;/P&gt;
&lt;PRE&gt;(?=\d)&lt;/PRE&gt;
&lt;P&gt;matches a single character that &lt;EM&gt;is&lt;/EM&gt; a digit just &lt;EM&gt;after&lt;/EM&gt; the current zero-length position.&lt;/P&gt;
&lt;P&gt;The tab character is inserted into the zero-length position to separate the non-digit from the digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt = "d试1(-是2^3([a]文/字789(+内\c容4$3";
// change paren to newline...
step1 = Regex( txt, "\(", "\!n", globalreplace );
// remove unwanted characters - + / \ ^ $ [ ] a..z A..Z
step2 = Regex( step1, "[-+/\\^$[\]a-zA-Z]", "", globalreplace );
// insert tab when character before is not a digit and character after is a digit
step3 = Regex( step2, "(?&amp;lt;!\d)(?=\d)", "\!t", globalreplace );
// add header
step4 = "aaa\!tbbb\!n" || step3;
// import the string without making a file on disk
Open( Char To Blob( step4 ), "text" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tabs separate fields" style="width: 222px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49689i961EE5E9BA544965/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="tabs separate fields" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;tabs separate fields&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:03:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595780#M79954</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-01T12:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595781#M79955</link>
      <description>&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Look at the code you write, a real enjoyment!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:09:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595781#M79955</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595782#M79956</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It can't learn these advanced techniques in a script guide.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:10:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595782#M79956</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T12:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595788#M79957</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;It is hard to make good examples for some features in regex. This is a good example for lookaround. I think I could do it without lookaround, but it would be more complicated. &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4160"&gt;@shannon_conners&lt;/a&gt; for the doc team: using positive and negative, ahead and behind, together, is what makes this compact and expressive (with a comment). It is an unusual situation, not mainstream usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:28:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595788#M79957</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-01T12:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595811#M79959</link>
      <description>&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to ask you a question about the underlying application:&lt;BR /&gt;I want to use JSL to solve more usage, can not use python and other tools.&lt;BR /&gt;Of course, I learned all of the JSL code from the many experts in this community.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My request is specifically:&lt;/P&gt;&lt;P&gt;how to restore protobuf(Google Protocol Buffe)-formatted binary text to JMP text ues JSL.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:49:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595811#M79959</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595816#M79961</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Like C# code coding code, how can you modify JSL?&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20230201205422.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49692i78BF7F90D2A87013/image-size/large?v=v2&amp;amp;px=999" role="button" title="20230201205422.png" alt="20230201205422.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;I did not succeed in rewriting it.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;h = [=&amp;gt; ];
u = "http://ds.m.emoney.cn/pick";
h["X-Protocol-Id"] = "8900";
h["X-Request-Id"] = "null";

b = Char To Blob( "~0A~0D~E5~BD~93~E6~97~A5~42~E7~82~B9~E8~82~A1~10~F2~DF~D2~09", "ascii~hex" );
rs = New HTTP Request( URL( u ), Method( "POST" ), JSON( b ), Headers( h ) );
rr = rs &amp;lt;&amp;lt; Send;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:59:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595816#M79961</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T12:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595818#M79963</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;This is just the general outline.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;The main problem is to solve how to write request parameters correctly in JSL.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 01 Feb 2023 13:05:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595818#M79963</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T13:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595825#M79964</link>
      <description>&lt;P&gt;Interesting &lt;A href="https://developers.google.com/protocol-buffers/docs/overview" target="_blank"&gt;https://developers.google.com/protocol-buffers/docs/overview&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It looks like you have two choices: write your own &lt;A href="https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md" target="_blank"&gt;https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md&lt;/A&gt; which would then work for many protocols,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or, easier and harder,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pick an existing one and translate. I have not looked at it, but I might try starting with a JAVA version and translate that to JSL. But then you get to repeat the translation for the next protocol.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be a pretty cool project to make a translator. I do not plan to do that.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 13:04:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595825#M79964</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-01T13:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Regex substitution?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595837#M79965</link>
      <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;Thank you so much Craige!&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I know it's a very difficult job.&lt;/SPAN&gt;&lt;SPAN class=""&gt;Thank you for writing a general framework, I will try to learn more knowledge to modify.&lt;/SPAN&gt;&lt;SPAN class=""&gt;Thank you for your efforts.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 13:11:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-Regex-substitution/m-p/595837#M79965</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-02-01T13:11:13Z</dc:date>
    </item>
  </channel>
</rss>

