Hello,
how it´s possible to add the international prefix to a national phone number?
I have the following number 0775188060 and want +49775188060.
Greetings
Hello,
I only import one country so all prefixes are same.
It´s not a mixed import, I import country by country so I only need to know how to replace the first zero with +49
I don´t have a field with the country prefix inside so I can not combinate two fields.
Greetings
Hi Loki555,
If there's good data quality on your source phone number, you can use a tMap to transform it using the following expression, given it is in String format :
"+49"+StringHandling.RIGHT(row1.phoneNumber,9)
Regards,
You're right ! You can do it with a tReplace, but you have to make sure that the phone numbers begin with a zero (by filtering with a tMap before), otherwise the prefix won't be concatenated.
See enclosed screenshot, with a simple regex that replace the 0 if it is the first character of the string.
Another way to do that, a little bit more obfuscated, but quicker !
"+49"+source.phoneNumber.substring(1,source.phoneNumber.length())
It replaces the first character of the string with "+49" in all cases, but without making sure it was a 0.
The key is to make sure you have good data quality on your source data !
It worked a while but now I get an error:
connecting to socket on port 3733
connected
Exception in component tMap_1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
I don´t understand why because I don´t change anythig. Unknown Source ... I deleted the expression
"+49"+Kundenadressen.AQAYNA.substring(1,Kundenadressen.AQAYNA.length())
and rewrite it, the source field is linked emediatly but when I restart I get the same error.
When I delete the expression I get no error.
Greetings
Peter
Beware of null/empty strings !
For this expression I gave you, I assume that the column containing the phone number is properly filled with
consistent data (I mean correct length, no null values, no empty strings, etc...).
If not, filter it upstream before applying this expression / correctly manage inconsistent data, otherwise you'll get NullPointerExceptions, or ArrayIndexOutOfBoundsExceptions when trying to substring.