如何替换字符串中的逗号 [英] How do replace a comma in a string

查看:398
本文介绍了如何替换字符串中的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i的字符串类似


i have string like

"Employee Name:john,age:45,salary:$1,000.45"

。当我分开时带有,的字符串,结果显示如下。

.When i split the string with "," the result is showing like this.

sAry[0]="Employee Name:john";
sAry[1]="age:45";
sAry[2]="salary:$1";
sAry[3]="000.45";





但是数组结果应该是这样的



But the array result should be like this

sAry[0]="Employee Name:john";
sAry[1]="age:45";
sAry[2]="salary:$1,000.45";





请帮我解决这个问题。

谢谢和最好的问候



Please help me to resolve this .
thanks and Best Regards

推荐答案

1,000.45

。当我用,分割字符串时,结果显示如下。

.When i split the string with "," the result is showing like this.

sAry[0]="Employee Name:john";
sAry[1]="age:45";
sAry[2]="salary:


1;
sAry [ 3 ] = 000.45;





但是数组结果应该是这样的



But the array result should be like this

sAry[0]="Employee Name:john";
sAry[1]="age:45";
sAry[2]="salary:


1,000.45;
1,000.45";





请帮我解决此问题。

谢谢和最好的问候



Please help me to resolve this .
thanks and Best Regards


这篇关于如何替换字符串中的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆