[SOLVED] Replacing the international code of a telephone number
Kate_Strydom
New Altair Community Member
Hi,
I am battling to replace the first two digits (international code) of a mobile phone number, for example, 27766270940 without RM replacing the other set of 27 within the number.
I need the mobile number to become 0766270940.
Can anyone assist me?
Thanks
Kate
I am battling to replace the first two digits (international code) of a mobile phone number, for example, 27766270940 without RM replacing the other set of 27 within the number.
I need the mobile number to become 0766270940.
Can anyone assist me?
Thanks
Kate
Tagged:
0
Answers
-
If it were me, I would make it a nominal attribute (if not already) and generate a new attribute where the function would be concat("0",suffix(att1,9))
Scott0 -
Thanks Scott. Your approach works well.
My attribute is already nominal. I was trying to use a start and replace function but they were not working very well.
Now I have some mobile numbers that need to be excluded or replaced as missing, once I have applied your approach. Basically I need to exclude any number with 00 or 01.
This expression if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number) is giving me errors.
Any suggestions?
Kate
0 -
Hi Kate,
i think you simply forgot a paranthesis. This should work:
you can by the way split this into two parts in Generate Attributes. Than it is a bit more readable.
if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number))
Cheers,
Martin0 -
Hi Martin,
My error when typing out the function. Sorry .
When I was driving home last night I realised that the prefix function is the problem. I cannot use a prefix to identify the 00 and 01 as this function will keep the first two digits. I want it to identify the first two digits and then exclude the ones that are not valid.
Got it. Now Scott's approach works perfectly for me.
Thanks Scott and Martin for your contribution; . It was a great help when you are all alone behind a pc with no other RM person to bounce ideas off.
if(starts(mobile_number, "00") || starts(mobile_number, "01") || starts(mobile_number, "02") || starts(mobile_number, "04"), " ", mobile_number)
Regards,
Kate0 -
No problem! it is always great to see, that people use our product!0