Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
aracelicv
Partner - Contributor II
Partner - Contributor II

How to work Regular Expressions in Qlik Sense?

Hello!

Has  anybody worked with Regular Expresions in Qlik Sense?, I already know 'RegEx' does not exist in Sense, nevertheless I need to evaluate the content of diferent dimensions into my data model, for instance:

Dimension: RFC

Content: CALE891013rr08

In order to create a flag , I need to evaluate the first 4 characters are capital letters, the next 6 characters are numbers, the next 2 are lower case  and the last 2 are numbers.

I´d really appreciate your help.

Thanks in advance.

8 Replies
Anil_Babu_Samineni

What is the issue here? May be look the use RegEx

Regular expression [A-Z] *

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
aracelicv
Partner - Contributor II
Partner - Contributor II
Author

Hello, thanks for answering, however is not what I need.

I already work using regular expressions in Qlik View, the issue is working them in QlikSense because in Qlik Sense does not exists RegEx and I have not found how to evaluate the content of my dimensions in Sense.

Anil_Babu_Samineni

True, I thought your initial group seems Qlikview. Anyway you may move this topic into Qliksense Branch

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
aracelicv
Partner - Contributor II
Partner - Contributor II
Author

I will, thanks for your time. Greetings

mirmiranda
Partner - Contributor
Partner - Contributor

Hi Araceli, maybe you can try this:

SET vFirst=1;
SET vSecond=5;

Do while vFirst<=4

Table:
Load
   RFC,
   if(ord(mid(RFC,$(vFirst),1))>= 65 and ord(mid(RFC,$(vFirst),1))<= 90,1,0) as Prove
resident MainTable;

//ord = code ascci, hence the search is from 65 to 90
//mid = returns the part of the string, in this case, letter by letter



Do while vSecond<=10

Tabla:
Load
   RFC,
   if(mid(RFC,$(vSecond),1)>= 0 and mid(RFC,$(vSecond),1)<= 9,1,0) as Prove2
resident MainTable;

//here the function ord is not necesary, and the search is between 0 and 9

At the end, you get 0 if one condition is not true, for example:

RFC                            Prove      Prove2
%DOG999999XXX          0          1
MEMM444444LLL            1          1
MEMM45M678KKK         1          0

I hope I've helped you

mirmiranda
Partner - Contributor
Partner - Contributor

Hi again Araceli.

I was thinking about your problem and my little solution too. I did many test with different cases,

and my solution it's wrong But I thought something simpler, only you need use several functions:


if(len(PurgeChar(mid(rfc,1,4),'_%&@()0123456789'))<4 or len(KeepChar(mid(rfc,5,6),'0123456789'))<6 or len(PurgeChar(mid(rfc,6,3),'_·$%&'))<3,0,1) as prove,


You get 0 if you have at leats a wrong character

amonjaras
Partner - Creator II
Partner - Creator II

A bit late, but a RegEx connector is included in the Qlik Web Connectors package. I have tested it, and it validates the RFC as you need to.

https://help.qlik.com/en-US/connectors/Subsystems/Web_Connectors_help/Content/Data-Source-Connectors...

simonaubert
Partner - Specialist II
Partner - Specialist II

Hello,

You can also vote for this idea.
https://community.qlik.com/t5/Qlik-Sense-Enterprise-Ideas/Native-Regex-support-for-Qlik-Sense/idi-p/...
Best regards,

Simon

Bi Consultant (Dataviz & Dataprep) @ Business & Decision