我有一个这样的json文件:
{
"title": "Pilot",
"image": [
{
"resource": "http://images2.nokk.nocookie.net/__cb20110227141960/notr/images/8/8b/pilot.jpg",
"description": "not yet implemented"
}
],
"content": "<p>The pilot ...</p>"
},
{
"title": "Special Christmas (Part 1)",
"image": [
{
"resource": "http://images1.nat.nocookie.net/__cb20090519172121/obli/images/e/ed/SpecialChristmas.jpg",
"description": "not yet implemented"
}
],
"content": "<p>Last comment...</p>"
}
我需要替换文件中所有资源值的内容,因此如果字符串具有以下格式:
"http://images1.nat.nocookie.net/__cb20090519172121/obli/images/e/ed/SpecialChristmas.jpg"
结果应该是:
"../img/SpecialChristmas.jpg"
有人可以告诉我如何匹配该模式以修改文件吗?
我试过这样的建议:
https://stackoverflow.com/a/4128192/521728
但我不知道如何适应我的情况。
提前致谢!