提问人:shivakumar 提问时间:10/8/2015 最后编辑:shivakumar 更新时间:10/8/2015 访问量:539
用于将 JSON 属性值包装在另一个字符串中的正则表达式
Regex to wrap JSON property value inside another string
问:
{ "url": "products/Sensors.html",
"thumbnailUrl":"/images/icons/no_image.png",
"translatedTitle": "sensors",
...
},
...
我想将值“localhost:8080”附加到以.png|jpg等结尾的属性“thumbnailUrl”
替换的值应为:
{ "url": "products/Sensors.html",
"thumbnailUrl":"localhost:8080/images/icons/no_image.png",
"translatedTitle": "sensors",
...
}
答:
0赞
Steve Tomlin
10/8/2015
#1
你为什么不直接做 Myobj.thumbnailUrl = “localhost:8080” + myobj.thumbnailUrl;
否则 Mynewstring = myexistingstring.replace(/(thumbnailUrl\“:\”)/,'$1'+'localhost:8080');
评论