cancel
Showing results for 
Search instead for 
Did you mean: 

Insert "-" into a string twice?

Former Member
0 Kudos

Hello,

I have a problem in a message mapping.

I have strings looking like this: 025954431

The output should look like this 025-954-431. A dash inserted after the third and sixth position.

Can I somehow solve this with the standard function "replaceString"?

Does anyone have an idea how this could be solved?

I appreciate any help I can get - Thank you very much!

Peter

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

you can use the substring function .

first take the first three characters from the string using the substring function then the substring output and constant "-" , concat using the concat function.

for example:

025954431-->substing(0,3)>025---->

concat()----->025-

constant("-")--->

In the same way you can proceed for ur final output.

if you still face the problem please reply me back.

Thanks

Rinku Gangwani

Former Member
0 Kudos

Thank you Rinku Gangwani - it worked with substring and concat!

Best regards,

Peter

Edited by: Peter420 on May 28, 2009 9:47 AM

Former Member
0 Kudos

Hi,

this (simple UDF would also be working:

return a.substring(0, 3) + "-" + a.substring(3, 6) + "-" + a.substring(6, 9);

Regards

Patrick

Former Member
0 Kudos

Thank you Patrick, I will try that too!

Best regards,

Peter

Answers (1)

Answers (1)

former_member200962
Active Contributor
0 Kudos
Can I somehow solve this with the standard function "replaceString"?

No....then how.....use FormatNumber Function

Regards,

Abhishek.