One Star

[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.
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

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

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

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

have you tried TABLE1.ROW.replaceAll("*"," ")
I think your replace problem was because you have single quotes.
One Star

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

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)
One Star

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

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

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

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.