我有這個字符串正則表達式來獲得之間的子串{}
dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"messages":[],"routes":{"fieldAliases":{"ObjectID":"ObjectID","Name":"Name","FirstStopID":"FirstStopID","LastStopID":"LastStopID","StopCount":"StopCount","Total_TravelTime":"Total_TravelTime","Total_Kilometers":"Total_Kilometers","Total_Miles":"Total_Miles","Shape_Length":"Shape_Length"},"geometryType":"esriGeometryPolyline","spatialReference":{"wkid":102100,"latestWkid":3857},"features":[{"attributes":{"ObjectID":1,"Name":"Location 1 - Location 2","FirstStopID":1,"LastStopID":2,"StopCount":2,"Total_TravelTime":0.44978725961372451,"Total_Kilometers":0.11520726003715911,"Total_Miles":0.07158647252368612,"Shape_Length":140.31608185601101},"geometry":{"paths":[[[-13046166.1984,4036530.1599000022],[-13046165.647399999,4036389.8448999971]]]}}]}});
,我想正則表達式來得到這個
{"messages":[],"routes":{"fieldAliases":{"ObjectID":"ObjectID","Name":"Name","FirstStopID":"FirstStopID","LastStopID":"LastStopID","StopCount":"StopCount","Total_TravelTime":"Total_TravelTime","Total_Kilometers":"Total_Kilometers","Total_Miles":"Total_Miles","Shape_Length":"Shape_Length"},"geometryType":"esriGeometryPolyline","spatialReference":{"wkid":102100,"latestWkid":3857},"features":[{"attributes":{"ObjectID":1,"Name":"Location 1 - Location 2","FirstStopID":1,"LastStopID":2,"StopCount":2,"Total_TravelTime":0.44978725961372451,"Total_Kilometers":0.11520726003715911,"Total_Miles":0.07158647252368612,"Shape_Length":140.31608185601101},"geometry":{"paths":[[[-13046166.1984,4036530.1599000022],[-13046165.647399999,4036389.8448999971]]]}}]}}
換句話說,我想在{...}之間的子串
任何想法?
謝謝!
你不應該使用得到JSON文件信息的正則表達式 – DreadfulWeather
你有什麼嘗試到目前爲止? – binarymason
爲什麼不執行'dojo.io.script.jsonp_dojoIoScript1._jsonpCallback()'函數,然後彈出奇怪的值你不想要的?你忘了正則表達式。正則表達式並不總是答案.. 1/10確定..但不是9/10。 ''dojo'應該在第二個想法中爲你執行那個函數,你應該有一個javascript Object do:'var i = {'a':'a','b':'b'};刪除我['a']; console.log(i);'和你保存自己SOOOO很麻煩!! –