我已經打在這一個我的頭,並不能找出一個正則表達式來實現以下目標:使用PHP的preg_replace解析出JSON字符串目標雙引號
輸入字符串(這是JSON數據通過許多其他JSON的)所包圍:
$string=..."natural_order":"12"...
其中12也可以是如「1.2」小數,也可以是像1288或1.288大。
所需的字符串:
..."natural_order":12...
使用PHP的preg_replace,到目前爲止,我已經得到了:
preg_replace('/[^natural_order:]+"/', '', $string);
但只返回:
"12"
任何想法是極大的讚賞!
'preg_replace'是修改目標字符串。提取一些你需要'preg_match'的東西。 http://stackoverflow.com/questions/5762739/how-can-i-parse-this-json-data/5762810#5762810 – mario