我需要提取它的一些html標籤內現有的JSON JSON內容。如何提取的名字從下面的JSON(鍵)值使用正則表達式如何採取使用正則表達式(正則表達式)在PHP
<div id="gwt_products_display_results" class="gwt_products_display_results">
<span class="JSON" style="display: none;">
{
"products": [
{
"targetURL": "/athena-mineral-fabric-by-the-yard/262682",
"listIndex": "0",
"minimumPrice": 20,
"categoryOnSale": "false",
"mfPartNumber": "FF010ATM",
"hasAtLeastOneBuyableAndPublishedItem": "true",
"attributes": [],
"partNumber": "b_FF010ATM",
"itemAsProduct": "true",
"iapAttribute": "",
"productDetailTargetURL": "/athena-mineral-fabric-by-the-yard/262682",
"iapAttributeCode": "",
"beanType": "bundle",
"name": "Athena Mineral Fabric by the Yard",
"maxListPrice": 0,
"thumbNail": "null",
"hasSaleSKUs": false,
"productId": "262682",
"currencyCode": "USD",
"hasMoreColors": false,
"xPriceLabel": "null",
"minListPrice": 0,
"maximumPrice": 20,
"iapAttributeDisplayName": "",
"shortDescription": "null",
"listId": "SEARCHRESULTS",
"categoryId": "null"
},
{
"targetURL": "/athena-slate-fabric-by-the-yard/262683",
"listIndex": "1",
"minimumPrice": 20,
"categoryOnSale": "false",
"mfPartNumber": "FF010ATS",
"hasAtLeastOneBuyableAndPublishedItem": "true",
"attributes": [],
"partNumber": "b_FF010ATS",
"itemAsProduct": "true",
"iapAttribute": "",
"productDetailTargetURL": "/athena-slate-fabric-by-the-yard/262683",
"iapAttributeCode": "",
"beanType": "bundle",
"name": "Athena Slate Fabric by the Yard",
"maxListPrice": 0,
"thumbNail": "null",
"hasSaleSKUs": false,
"productId": "262683",
"currencyCode": "USD",
"hasMoreColors": false,
"xPriceLabel": "null",
"minListPrice": 0,
"maximumPrice": 20,
"iapAttributeDisplayName": "",
"shortDescription": "null",
"listId": "SEARCHRESULTS",
"categoryId": "null"
},
{
"targetURL": "/typewriter-keys-giclee/261307",
"listIndex": "2",
"minimumPrice": 259,
"categoryOnSale": "false",
"mfPartNumber": "WD813",
"hasAtLeastOneBuyableAndPublishedItem": "true",
"attributes": [
{
"S7 - Overlay 1": "blank"
}
],
"partNumber": "p_WD813",
"itemAsProduct": "true",
"iapAttribute": "",
"productDetailTargetURL": "/typewriter-keys-giclee/261307",
"iapAttributeCode": "",
"beanType": "product",
"name": "Typewriter Keys Giclee",
"maxListPrice": 0,
"thumbNail": "null",
"hasSaleSKUs": false,
"productId": "261307",
"currencyCode": "USD",
"hasMoreColors": false,
"xPriceLabel": "null",
"minListPrice": 0,
"maximumPrice": 259,
"iapAttributeDisplayName": "",
"shortDescription": "null",
"listId": "SEARCHRESULTS",
"categoryId": "null"
}
]
}
</span>
</div>
我所到目前爲止已經試過被
<span class="JSON" style="display: none;">([\s\S]+?)<\/span>
爲什麼???只需使用'json_decode'。 – enenen
爲什麼對於世界上所有可能被認爲是聖潔的人來說,你想要在像JSON這樣的數據結構上使用正則表達式? __Parse__它到一個對象/數組中,並直接或通過循環訪問你想要的值。 – CBroe
如果您打算放棄'json_encode()',寫自己的功能完善的JSON解析器,你可能需要比正則表達式更因爲JSON允許任意元素的無限嵌套層次。你在尋找這樣的夏天做什麼? –