动态字符串替换 [英] Dynamic String Replace

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

问题描述



我有一个动态生成的字符串,该字符串基本上是JSON字符串.每次生成字符串时,字符串中的几个单词都会更改,我该如何解析这些单词,以便用自己的某个常量单词替换它们.

字符串看起来像这样
"end_location":{" Za ":17.44716," $ a ":78.37790999999993},"start_address":"Mumbai Rd,Madhura Nagar Colony,Madhapur,Hyderabad,Andhra印度普拉达什," start_location:{" Za :17.4243," $ a :78.37761999999998},

在此示例字符串之前和之后有更多数据.现在我得到的结果是Za和$ a(以粗体显示),它们总是不断更改为不同的值.我该如何用一个常数词替换这些词.

Hi,

I have a string which is generated dynamically, the string is basically an JSON string. Each time the string is generated few words in the string gets changing, how can i parse these words so that i replace them with some constant word of my own.

The string looks like this
"end_location":{"Za":17.44716,"$a":78.37790999999993},"start_address":"Mumbai Rd, Madhura Nagar Colony, Madhapur, Hyderabad, Andhra Pradesh, India","start_location":{"Za":17.4243,"$a":78.37761999999998},

With even more data before and after this sample string. Now the result what i get has Za and $a(in bold) which always keeps changing to different value. How can i replace these words with some constant word.

推荐答案

a :78.37790999999993}," start_address:" Mumbai Rd,Madhura Nagar Colony,印度,安得拉邦海得拉巴的Madhapur","start_location":{" Za ":17.4243,"
a":78.37790999999993},"start_address":"Mumbai Rd, Madhura Nagar Colony, Madhapur, Hyderabad, Andhra Pradesh, India","start_location":{"Za":17.4243,"


a ": 78.37761999999998},

在此示例字符串之前和之后有更多数据.现在我得到的结果是Za和
a":78.37761999999998},

With even more data before and after this sample string. Now the result what i get has Za and


a(粗体),它们总是不断更改为不同的值.我该如何用一个常数词代替这些词.
a(in bold) which always keeps changing to different value. How can i replace these words with some constant word.


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

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