Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Tasfiahm
Creator
Creator

Pattern Check

It is silly but I was trying to check alphanumeric pattern and than replace it with a string. I tried to use  matches, replaceAll and many more thing. In my findings I understanding that I am not defining the pattern correctly. I hope you guys can help with this silly issue.

Input as string Expected output
orange orange
1orange not alphabet
1--2 not alphabet
2~9 not alphabet
mango mango
12~banana not alphabet

 

 

my code:

 

StringHandling.LEN(row1.NAME) ==0 ? "":
row1.NAME.matches("^[0-9|A-Z]{3}.*") ? "not alphabet" :

row1.NAME

 

 

Labels (2)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

row1.NAME.matches("^[a-zA-Z]*$") ? row1.NAME : “non alpha”

Add null check

View solution in original post

4 Replies
Anonymous
Not applicable

Try to use this, check the length, then if it contains numeric then populate with "not alphabet"  else the value of string

StringHandling.LEN(row1.NAME) ==0 ? "":
row1.NAME.Contains("[0-9|") ? "not alphabet" :

row1.NAME

Tasfiahm
Creator
Creator
Author

It Didn't work for me:

 

input = 1~6

 

Relational.ISNULL(row1.NAME) ? "" :
StringHandling.LEN(row1.NAME) ==0 ? "" :
row1.NAME.contains("[0-9]") ? "not alphabet" : row1.NAME

 

 

I also tried to use IS_ALPHA but it its giving wrong output incase of space between the string "Black Berry" 

 

Relational.ISNULL(row1.NAME) ? "" :
StringHandling.LEN(row1.NAME) ==0 ? "" :
StringHandling.IS_ALPHA(row1.NAME) ? row1.NAME : "not alphabet"  

 

 

akumar2301
Specialist II
Specialist II

row1.NAME.matches("^[a-zA-Z]*$") ? row1.NAME : “non alpha”

Add null check
Anonymous
Not applicable

yes i agree with @uganesh that will take only alphabets in the string