1 Reply Latest reply: Feb 6, 2013 7:53 AM by Jason Newman RSS

    Scripting using RegEx


      I wanted to copy the following SQLServer statement in my script:


      WHEN @Select(Injury Detail\Injury Codes) LIKE '[289]D[0123456789][1023456789]'


      From searching the web it appears that RegEx is the best solution. I went to the following web site




      and using the example I copied the code from the module editor as directed.

      I then created the following in my script:


















          if(RegExTest(IC, '^[289]D[0-9]$')= -1, 'Yes', 'No') as ValidOD       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 & CLAIMANT_NO as ClaimNo,      INJURYCODES; SQL SELECT     CLAIM_NO,     CLAIMANT_NO,     INJURYCODES FROM DB700RXX.dbo.STAT; //Create detail InjuryCode: LEFT JOIN (Injury) LOAD ClaimNo,      if(RegExTest(INJURYCODES, '^[289]D[0-9]$')= -1, 'Yes', 'No') as ValidOD

      Resident Injury ;


      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?




        • Re: Scripting using RegEx

          I have found the solution, so just in case someone has the same question in the future:


          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:


          if(RegExTest(INJURYCODES, '^[289]D[0-9]{2}$',1)= -1, 'Yes','No') as ValidOD