找回密码
 加入
搜索
查看: 2046|回复: 6

[效率算法] [已解决]求个正则,怎么解决斜杠的正则?

[复制链接]
发表于 2017-5-25 15:32:20 | 显示全部楼层 |阅读模式
本帖最后由 80107671 于 2017-5-26 09:18 编辑

以下是json文件内容。
{
   "case1":{
   "name" : "PI_Memory_DDR4_DIMMMaximumMemory_L",
   "category" : "Memory",
   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\memory\\PI_Memory_DDR4_DIMMMaximumMemory_L.py",
   "parameters" : "--platform=HAHA --memory_num=1 --memory_size=16",
   "logpath" : "%LC_RESULT_PATH%\\PI_Memory_DDR4_DIMMMaximumMemory_L",
   "critical" : "0",
   "pinned" : "0",
   "EXECUTION_FROM" : "network",
   "timeout" : "8000"
  },
   "case2":{
   "name" : "PI_Networking_FortPark_ConnectivityEnableDisable_L",
   "category" : "Networking",
   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\networking\\PI_Networking_FortPark_ConnectivityEnableDisable_L.py",
   "parameters" : "--platform=HAHA --dhcpip=192.168.1.6 --cycle=5 --FortPark="10GbE SFP+"",
   "logpath" : "%LC_RESULT_PATH%\\PI_Networking_FortPark_ConnectivityEnableDisable_L",
   "critical" : "0",
   "pinned" : "0",
   "EXECUTION_FROM" : "network",
   "timeout" : "5400"
  },
   "case3":{
   "name" : "PI_PCIe_PCIModelAvailability_L",
   "category" : "PCIe",
   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\pcie\\PI_PCIe_PCIModelAvailability_L.py",
   "parameters" : "--platform=HAHA --pciDevice="display" --searchStr="Display,Vendor 10D;NVIDIA Corporation GT218" --LinkStatus="2.5 GT/s,x8;2.5GT/s,x8" --LinkCapabilities="2.5 GT/s,x16;2.5GT/s,x16"",
   "logpath" : "%LC_RESULT_PATH%\\PI_PCIe_PCIModelAvailability_L",
   "critical" : "0",
   "pinned" : "0",
   "EXECUTION_FROM" : "network",
   "timeout" : "5400"
  }
}
我用以下正则发现parameters这一行如果有\杠的,则parameters后面的内容就没有了。这个如何解决,求解, 如图片中12行\后面就没内容了。
StringRegExp($jsonfr,': "([^\"]+)',3)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2017-5-25 17:05:00 | 显示全部楼层
不知道是不是要"parameters"后面这些。

### 友情提示:本脚本由 Au3 正则测试工具 于 2017年05月25日17点02分23秒 自动生成,不保证其正确性,请自行修改测试 ###
#include <Array.AU3>
$string = _
'{' & @CRLF & _
'   "case1":{' & @CRLF & _
'   "name" : "PI_Memory_DDR4_DIMMMaximumMemory_L",' & @CRLF & _
'   "category" : "Memory",' & @CRLF & _
'   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\memory\\PI_Memory_DDR4_DIMMMaximumMemory_L.py",' & @CRLF & _
'   "parameters" : "--platform=HAHA --memory_num=1 --memory_size=16",' & @CRLF & _
'   "logpath" : "%LC_RESULT_PATH%\\PI_Memory_DDR4_DIMMMaximumMemory_L",' & @CRLF & _
'   "critical" : "0",' & @CRLF & _
'   "pinned" : "0",' & @CRLF & _
'   "EXECUTION_FROM" : "network",' & @CRLF & _
'   "timeout" : "8000"' & @CRLF & _
'  },' & @CRLF & _
'   "case2":{' & @CRLF & _
'   "name" : "PI_Networking_FortPark_ConnectivityEnableDisable_L",' & @CRLF & _
'   "category" : "Networking",' & @CRLF & _
'   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\networking\\PI_Networking_FortPark_ConnectivityEnableDisable_L.py",' & @CRLF & _
'   "parameters" : "--platform=HAHA --dhcpip=192.168.1.6 --cycle=5 --FortPark=\"10GbE SFP+\"",' & @CRLF & _
'   "logpath" : "%LC_RESULT_PATH%\\PI_Networking_FortPark_ConnectivityEnableDisable_L",' & @CRLF & _
'   "critical" : "0",' & @CRLF & _
'   "pinned" : "0",' & @CRLF & _
'   "EXECUTION_FROM" : "network",' & @CRLF & _
'   "timeout" : "5400"' & @CRLF & _
'  },' & @CRLF & _
'   "case3":{' & @CRLF & _
'   "name" : "PI_PCIe_PCIModelAvailability_L",' & @CRLF & _
'   "category" : "PCIe",' & @CRLF & _
'   "path" : "python C:\\BKC\\BKC_Automation\\scripts\\bkc_case\\linux\\pcie\\PI_PCIe_PCIModelAvailability_L.py",' & @CRLF & _
'   "parameters" : "--platform=HAHA --pciDevice=\"display\" --searchStr=\"Display,Vendor 10D;NVIDIA Corporation GT218\" --LinkStatus=\"2.5 GT/s,x8;2.5GT/s,x8\" --LinkCapabilities=\"2.5 GT/s,x16;2.5GT/s,x16\"",' & @CRLF & _
'   "logpath" : "%LC_RESULT_PATH%\\PI_PCIe_PCIModelAvailability_L",' & @CRLF & _
'   "critical" : "0",' & @CRLF & _
'   "pinned" : "0",' & @CRLF & _
'   "EXECUTION_FROM" : "network",' & @CRLF & _
'   "timeout" : "5400"' & @CRLF & _
'  }' & @CRLF & _
'}'
Local $Array = StringRegExp($string, '"parameters" : "(.*?),' ,3)
For $i = 0 To UBound($Array) - 1
    
NEXT
;以下为测试结果:
If Not @Error Then   MsgBox(0, '匹配数量: ' & UBound($array), '其中$array[0]数组为: ' & $array[0])
_ArrayDisplay($Array, UBound($Array))
发表于 2017-5-25 22:06:13 | 显示全部楼层
http://www.autoitx.com/forum.php ... &highlight=json《真正的JSON解析库,VB6.0封装COM接口》或许这个贴能帮到你
发表于 2017-5-25 22:35:44 | 显示全部楼层
(?m): "(.*)",?\v*
发表于 2017-5-26 08:00:08 | 显示全部楼层
:\s*?"(.*?)"
 楼主| 发表于 2017-5-26 09:18:20 | 显示全部楼层
回复 4# zghwelcome


    谢谢,完美。
发表于 2017-5-26 10:31:12 | 显示全部楼层
:.?"(\V+)"
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 01:49 , Processed in 0.077071 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表