Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Trying to use StringHandling.CHANGE to replace "*" with " ".

Hi,
I have a input row wich can contain "*", and I wan't to replace "*" with " " (e.g. "asd*asd" -> "asd asd"). I tried using this code in the output row expression in tMap:
StringHandling.CHANGE(TABLE1.ROW,"*"," ")

But I get this error:
Exception in component tMap_1
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at routines.StringHandling.CHANGE(StringHandling.java:87)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.tOracleInput_1Process(Preparar_Tablas.java:3490)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.runJobInTOS(Preparar_Tablas.java:17858)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.main(Preparar_Tablas.java:17726)

I also tried using:
TABLE1.ROW.replace('*',' ')

But I get this error:
Exception in component tMap_1
java.lang.NullPointerException
at modelo181.preparar_tablas_0_1.Preparar_Tablas.tOracleInput_1Process(Preparar_Tablas.java:3490)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.runJobInTOS(Preparar_Tablas.java:17857)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.main(Preparar_Tablas.java:17725)

Sorry if this is a newbie question, thanks in advance,
Khor.
Labels (3)
1 Solution

Accepted Solutions
janhess
Creator II
Creator II

Presumably you have a null value in table1.row. Try ! Relational.ISNULL(TABLE1.ROW1)?TABLE1.ROW.replaceALL("*"," "):""

View solution in original post

4 Replies
janhess
Creator II
Creator II

have you tried TABLE1.ROW.replaceAll("*"," ")
I think your replace problem was because you have single quotes.
Anonymous
Not applicable
Author

Hi janhess, thanks for your reply
I tried TABLE1.ROW.replaceALL("*"," ") and it throws an error too:
Exception in component tMap_1
java.lang.NullPointerException
at modelo181.preparar_tablas_0_1.Preparar_Tablas.tOracleInput_1Process(Preparar_Tablas.java:3490)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.runJobInTOS(Preparar_Tablas.java:17857)
at modelo181.preparar_tablas_0_1.Preparar_Tablas.main(Preparar_Tablas.java:17725)
janhess
Creator II
Creator II

Presumably you have a null value in table1.row. Try ! Relational.ISNULL(TABLE1.ROW1)?TABLE1.ROW.replaceALL("*"," "):""
Anonymous
Not applicable
Author

Hi janhess,
You're right, there is null values coming from the lookup table and the java function can't work with them, that's why I was getting NullPointerException errors.
Thank you,
Khor.