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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

To remove unnecessary characters in string

Hi,
I just wonder how do I wants to removed certain character or word in string.
For example, there is string with data "good-morning". Then i wants to remove "-morning" and then the data will become as "good" only.
Plz help me 0683p000009MPcz.png

Regards,
Kal
Labels (2)
10 Replies
Anonymous
Not applicable
Author

Hi,
tFileInputPositionalComponent and tFileInputRegex component can meet your needs.
Best regards
Sabrina
janhess
Creator II
Creator II

Or in a tMap you could use column_name.replace("-morning","")
Anonymous
Not applicable
Author

Hi, ae_kel29
I just wonder how do I wants to removed certain character or word in string.

If your requirement is just the example you set, the way @janhess provided is very good for you.
But if your real work have a lot of strings, it suggestion that use column_name.substring(int startIndex, int endIndex) in tMap.
Best regards
Sabrina
janhess
Creator II
Creator II

column_name.substring(int startIndex, int endIndex) in tMap.

This assumes the string to replace is in a fixed position.
Anonymous
Not applicable
Author

Hi,
Yep, it depends on the replaced strings.
Best regards
Sabrina
_AnonymousUser
Specialist III
Specialist III

Hi There
How do i remove stranges caracteres li "" on tmap when passing a string??
Anonymous
Not applicable
Author

Hi  eliton,
For you requirement, y ou can use method "ReplaceAll(string s1, string s2)" in tMap component expression.
Best regards
Sabrina
Anonymous
Not applicable
Author

replaceAll function throws null pointer expression when no matching string found.

manodwhb
Champion II
Champion II

@ContactNitesh89,can you try the below one.

 

column_name==null ||"".equals(column_name) ? column_name : column_name.replaceAll("-morning","")