<?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: Regex issue with escaped characters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79581#M36764</link>
    <description>Interesting thought. In Perl \ escapes only the next character.&lt;BR /&gt;&lt;BR /&gt;But if this is different in JMP, then this should work:&lt;BR /&gt;&lt;BR /&gt;Show(Regex("abcdef[ghi]", "([^\[\]*)\[\([^\]\].*)\]\", "\1{\2}”))&lt;BR /&gt;&lt;BR /&gt;Unfortunately, it doesn’t:&lt;BR /&gt;&lt;BR /&gt;Regex: expecting ')' at position 21 in pattern '([^\]*)\[\([^\].*)\]\'. in access or evaluation of 'Regex' , Regex/*###*/("abcdef[ghi]", "([^\]*)\!\[\([^\].*)\]\", "\1{\2}")&lt;BR /&gt;</description>
    <pubDate>Thu, 18 Oct 2018 17:23:58 GMT</pubDate>
    <dc:creator>john_madden</dc:creator>
    <dc:date>2018-10-18T17:23:58Z</dc:date>
    <item>
      <title>Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79540#M36746</link>
      <description>&lt;P&gt;I'm having a problem with regex and bracket characters.&lt;/P&gt;&lt;P&gt;This JSL snippet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(Regex("abcdef[ghi]", "([^\[]*)\[([^\]]*)\]", "\1{\2}"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;doesn't work in JMP (14.1). It gives the following error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Unexpected "([^]*)\[([^\]]*)\]", "\1{\2}"))". Perhaps there is a missing "," or ")".
Trying to parse arguments of function "Regex".&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this is valid regex in my Perl regex tester. ( I use Patterns on OS X.) In that environment, inputting:&lt;/P&gt;&lt;PRE&gt;abcdef[ghi]&lt;/PRE&gt;&lt;P&gt;to the Regular Expression&lt;/P&gt;&lt;PRE&gt;([^\[]*)\[([^\]]*)\]&lt;/PRE&gt;&lt;P&gt;using the&amp;nbsp;Replacement value of&lt;/P&gt;&lt;PRE&gt;$1{$2}&lt;/PRE&gt;&lt;P&gt;yields the result&lt;/P&gt;&lt;PRE&gt;abcdef{ghi}&lt;/PRE&gt;&lt;P&gt;(The Perl expression is&lt;/P&gt;&lt;PRE&gt;$searchText =~ s/([^\[]*)\[([^\]]*)\]/$1{$2}/gism;&lt;/PRE&gt;&lt;P&gt;).&lt;/P&gt;&lt;P&gt;What is going on? Does JMP regex engine need some other way of escaping bracket characters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:28:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79540#M36746</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-10-18T14:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79542#M36748</link>
      <description />
      <pubDate>Thu, 18 Oct 2018 19:12:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79542#M36748</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-10-18T19:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79553#M36750</link>
      <description>&lt;P&gt;P.S. Weirdly, this works fine in JMP:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(Regex("abcdef(ghi)", "([^(]*)\(([^\)]*)\)", "\1[\2]"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;yielding the correct result:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex("abcdef(ghi)", "([^(]*)\(([^\)]*)\)", "\1[\2]") = "abcdef[ghi]";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 16:30:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79553#M36750</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-10-18T16:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79573#M36758</link>
      <description>&lt;P&gt;I wonder if it's because you have the string escape character sequence "\[" in your string.&amp;nbsp; That sequence means treat everything afterwards as a string until you hit "]\".&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;"([^&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;\[&lt;/STRONG&gt;&lt;/FONT&gt;]*)&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;\[&lt;/STRONG&gt;&lt;/FONT&gt;([^\]]*)&lt;FONT color="#000000"&gt;\]&lt;/FONT&gt;"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:10:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79573#M36758</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-10-18T17:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79577#M36762</link>
      <description>&lt;P&gt;This will do what you want.&amp;nbsp; Had to escape the two escape sequences!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(Regex("abcdef[ghi]", "([^\[\[]\]*)\[\[]\([^\]]*)\]", "\1{\2}"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Regex("abcdef[ghi]", "([^\!\[]*)\!\[([^\]]*)\]", "\1{\2}") = "abcdef{ghi}";&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:14:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79577#M36762</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-10-18T17:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79581#M36764</link>
      <description>Interesting thought. In Perl \ escapes only the next character.&lt;BR /&gt;&lt;BR /&gt;But if this is different in JMP, then this should work:&lt;BR /&gt;&lt;BR /&gt;Show(Regex("abcdef[ghi]", "([^\[\]*)\[\([^\]\].*)\]\", "\1{\2}”))&lt;BR /&gt;&lt;BR /&gt;Unfortunately, it doesn’t:&lt;BR /&gt;&lt;BR /&gt;Regex: expecting ')' at position 21 in pattern '([^\]*)\[\([^\].*)\]\'. in access or evaluation of 'Regex' , Regex/*###*/("abcdef[ghi]", "([^\]*)\!\[\([^\].*)\]\", "\1{\2}")&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:23:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79581#M36764</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-10-18T17:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79591#M36769</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp;is correct. JMP made an unfortunate choice, long before the regex support was added, to allow the \[ ... ]\ anywhere in a string to mean ignore all special character meanings in between. To get the literal text \[ requires using JMP's other escape mechanism \!X, replacing X with \ , to represent a \ that doesn't combine with the [ when JMP is parsing the JSL. Later, when regex parses the pattern, the \ is followed by the [ which in turn tells regex to ignore the special meaning of [ and treat it as a simple character.&lt;/P&gt;
&lt;P&gt;I'm thinking about how to make this easier, thanks for the report!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 18:12:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79591#M36769</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2018-10-18T18:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79592#M36770</link>
      <description>&lt;P&gt;The backslash character is used to escape the next character, in general, just like the Perl flavor but it also denotes special character sets such as &lt;STRONG&gt;\s&lt;/STRONG&gt; for space characters or &lt;STRONG&gt;\d&lt;/STRONG&gt; for digits. You would not succeed if you wanted to enter &lt;STRONG&gt;s&lt;/STRONG&gt; by entering &lt;STRONG&gt;\s&lt;/STRONG&gt; in the regex. The escape sequence &lt;STRONG&gt;\[&lt;/STRONG&gt; is special and it is paired with the closing &lt;STRONG&gt;]\&lt;/STRONG&gt; sequence. That is, it is not the way to include the literal &lt;STRONG&gt;]&lt;/STRONG&gt; character. It will instead include the string up to the closing escape sequence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this example in exploded form (four capturing groups) that illustrates how they work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex(
	"abcdef[ghi]",
	"([^\[\[]\]*)" || "(\[\[]\)" || "([^\[\[]\]*)" || "(\[\]]\)",
	"\1-\2-\3-\4"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 18:15:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79592#M36770</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-10-18T18:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79610#M36773</link>
      <description>&lt;P&gt;Aha! Thank you both pmroz and Mark. With some fiddling, I figured out how to do what I want.&lt;BR /&gt;1. For the benefit of the JSL interpreter, first escape the entire regex string using \[…]\.&lt;BR /&gt;2. Then, for the benefit of the Regex engine, escape the bracket characters as you would in Perl.&lt;BR /&gt;The result is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(Regex("abcdef[ghi]", "\[([^\[]*)\[([^\]]*)\]]\", "\1{\2}"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which yields the expected result of;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;abcdef{ghi}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Breaking down the string we have:&lt;BR /&gt;&lt;BR /&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp;\[ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for JSL&lt;BR /&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp;[([^\[]*)\[([^\]]*)\] &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for the Regex engine (just as in Perl)&lt;BR /&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp;]\ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for JSL&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;Phew!!!&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 19:11:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/79610#M36773</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-10-18T19:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/83185#M37454</link>
      <description>&lt;P&gt;As a follow up, I learned&amp;nbsp;something I didn't know about Perl regex, and that is that the engine is smart enough to know that "[^[]" means "everything but "[". That is to say, the engine is clever enough not to insist on a backslash before the second "[" in this particular context. It also knows how to interpret "[^abc[]" correctly.&lt;/P&gt;&lt;P&gt;It appears that the engine in JMP understands this as well.&lt;/P&gt;&lt;P&gt;So I was making more trouble for myself than I needed to by escaping&amp;nbsp;the "[".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 22:37:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/83185#M37454</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-11-13T22:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236458#M46664</link>
      <description>&lt;P&gt;How to deal with this combination:The range of reservations is from ":[{" start、 to end "]".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;abcdef&lt;/CODE&gt;{:[[ghi]]:[{op},{q}]}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT&gt;&lt;FONT&gt;Need to get：&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;[{op},{q}]&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class="src"&gt;So how to write JSL. Thank you very much!&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 09:52:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236458#M46664</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2019-11-26T09:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236472#M46667</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class="src"&gt;&lt;SPAN class="transSent"&gt;I made a mistake.&lt;/SPAN&gt;&lt;SPAN class="transSent"&gt;Writing code like this doesn't get you the right result.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;c=Regex("abcdef{:[[ghi]]:[{op},{q}]}", ":\[\[]\([^\]]*)\]", "[\1]");&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 26 Nov 2019 11:46:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236472#M46667</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2019-11-26T11:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Regex issue with escaped characters</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236482#M46668</link>
      <description>&lt;P&gt;It doesn't work either:&lt;BR /&gt;c=Regex("abcdef{:[[ghi]]:[{op},{q}]}", ":\[\[]\!007B([^\]]*)\]", "[{\1]");&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 11:58:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-issue-with-escaped-characters/m-p/236482#M46668</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2019-11-26T11:58:42Z</dc:date>
    </item>
  </channel>
</rss>

