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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
lmit
Creator II
Creator II

substring in a string

Hi All,

 

I have a input data which has a special character  like

 

"maths*science*English"

 

my ouput should have data like

science

English

 

the position of the special character is not fixed and I should consider the occurrence of special character based on the other column i.e., if the other column has data like 3 I should consider the 3rd occurrence of the special character.

 

 

Thanks in Advance,

Lmit 

 

 

 

Labels (2)
10 Replies
Anonymous
Not applicable

If there is only one special string *

row7.test.contains ("*")
?
StringHandling.EREPLACE(row7.test, "*", "")
:row7.test

 

or

if you have multiple special characters use the code in routines. so it will and , gives you good result.

Manish 

manodwhb
Champion II
Champion II

@lmit ,check the below example. works fine for your case.

Untitled.pngUntitled.png

lmit
Creator II
Creator II
Author

@manodwhb thanks for your reply

 

I cant use tnormalize component because I have to sometimes consider the data before the special character or in between special character I need only part of the string Like

 

if my data is "ma*thsSci*eng"

 

for some cases I need to consider my output to be only thsSci or eng

 

I don't want to increase the records

 

Thanks,

lmit

lmit
Creator II
Creator II
Author

Hi Manish,

 

I tried your code but it will replace special character or will displace the string.but I need part of the string based on special character

 

Thanks,

lmit

manodwhb
Champion II
Champion II

@lmit,check this.

 

input data:-

 

maths*science*English
ma*thsSci*eng

 

output data:-

 

science
thsSci

 

Untitled.pngUntitled.png

lmit
Creator II
Creator II
Author

@manodwhb  thanks for your code its displaying "thsSci"

 

but how about "eng" in the string

 

 

Code displays data from first occurrence to second occurrence how can I make it generic ?

 

Thanks,

lmit

manodwhb
Champion II
Champion II

@lmit ,can you explain with data what exactly do you want?

manodwhb
Champion II
Champion II

@lmit ,are you looking for below way?

 

Untitled.pngUntitled.png

lmit
Creator II
Creator II
Author

@manodwhb , my requirement is

 

source file :

id, data, position field

1, abc*dfec*eng, 1

2,  abc*dfec*eng*math, 3

 

output should be

1,dfec

2,math

 

Based on the position field value , the data column should have the data

 

for example 2 id , the position field is 3 which means the data in data column should start from 3 occurrence of the special character and should end till the next occurrence

 

Hope I explained your properly

 

Thanks,

lmit