<?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: Scripting using RegEx in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Scripting-using-RegEx/m-p/405799#M697792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have found the solution, so just in case someone has the same question in the future:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The RegExTest has 3 parameters and the third one appears to be optional, but if it is not specified the performance is very poor. The 3 parameter is IgnoreCase, 1 for yes and 0 for no. So the following processed much quicker:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(RegExTest(INJURYCODES, '^[289]D[0-9]{2}$',1)= -1, 'Yes','No') as ValidOD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Feb 2013 12:53:57 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-02-06T12:53:57Z</dc:date>
    <item>
      <title>Scripting using RegEx</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-using-RegEx/m-p/405798#M697791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I wanted to copy the following SQLServer statement in my script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN @Select(Injury Detail\Injury Codes) LIKE '[289]D[0123456789][1023456789]'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From searching the web it appears that RegEx is the best solution. I went to the following web site &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.qlikfix.com/2010/10/18/regular-expressions-in-the-load-script/"&gt;http://www.qlikfix.com/2010/10/18/regular-expressions-in-the-load-script/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and using the example I copied the code from the module editor as directed.&lt;/P&gt;&lt;P&gt;I then created the following in my script:&lt;/P&gt;&lt;P&gt;Injurydata:&lt;/P&gt;&lt;P&gt;LOAD * INLINE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8132&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9D04&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7a01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2D01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7A02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8D14&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//valid?&lt;/P&gt;&lt;P&gt;ICode:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IC,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(RegExTest(IC, '^[289]D[0-9]&lt;SPAN __jive_macro_name="2"&gt;$')= -1, 'Yes', 'No') as ValidOD 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
Resident Injurydata; 

This code works as required. 

I then tried to use the same code on the database. The SQL load below works without the RegExTest code, but when I add the RegExTest code the load freezes :

// STAT table - 700RXX
Injury:
LOAD CLAIM_NO &amp;amp; CLAIMANT_NO as ClaimNo,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INJURYCODES;
SQL SELECT 
&amp;nbsp;&amp;nbsp;&amp;nbsp; CLAIM_NO,
&amp;nbsp;&amp;nbsp;&amp;nbsp; CLAIMANT_NO,
&amp;nbsp;&amp;nbsp;&amp;nbsp; INJURYCODES
FROM DB700RXX.dbo.STAT;


//Create detail
InjuryCode:
LEFT JOIN (Injury)
LOAD ClaimNo,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(RegExTest(INJURYCODES, '^[289]D[0-9]&lt;/SPAN&gt;$')= -1, 'Yes', 'No') as ValidOD &lt;/P&gt;&lt;P&gt;Resident Injury ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using exactly the same code as in the in line load on the same Qlikview document, so can someone tell me why the RegExTest code does not work with the SQLServer load?&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Jason &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 15:42:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-using-RegEx/m-p/405798#M697791</guid>
      <dc:creator />
      <dc:date>2013-02-05T15:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting using RegEx</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-using-RegEx/m-p/405799#M697792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have found the solution, so just in case someone has the same question in the future:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The RegExTest has 3 parameters and the third one appears to be optional, but if it is not specified the performance is very poor. The 3 parameter is IgnoreCase, 1 for yes and 0 for no. So the following processed much quicker:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(RegExTest(INJURYCODES, '^[289]D[0-9]{2}$',1)= -1, 'Yes','No') as ValidOD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2013 12:53:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-using-RegEx/m-p/405799#M697792</guid>
      <dc:creator />
      <dc:date>2013-02-06T12:53:57Z</dc:date>
    </item>
  </channel>
</rss>

