找回密码
 加入
搜索
查看: 4510|回复: 5

[系统综合] 求助 利用正则 将注册表汇出的REG 数据分成 一段一段的

  [复制链接]
发表于 2014-4-28 02:13:49 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2014-4-28 02:19 编辑

現有 匯出的  登錄檔  資料 內容 如下:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Canon]
@=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\
  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\
"SOFT"=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\
  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\
  f4,01,00,00,01,02,00,00,14,02,00,00,00,00,FF,00,00,00,12,00,01,00,00,00,00,\
  00,00,00,FF,25,35,66
"DEBUG"=hex:00,00,00,00,bc,00,00,00,02,00,01,00,bc,00,00,00,1a,00,00,00,00,00,00,\
  00,d8,00,00,00,00,00,00,00,00,00,00,00,d8,00,00,00,18,00,00,00,00,00,00,00,\
  f0,00,00,00,00,00,00,00,00,00,00,00,f0,00,00,00,00,00,00,00,00,00,00,00,f0,\
  00,58,00,03,00,00,00,00,00,14,00,5b,03,02,00,01,01,00,00,00,00,00,01,00,00,\
  00,00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\
  00,00,00,24,00,44,00,02,00,01,05,00,00,00,00,00,05,15,00,00,00,80,cb,af,71,\
  92,18,ec,25,2e,1c,29,2d,f4,01,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,\
  02,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,41,00,64,00,6d,00,\
  69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,18,00,a1,7b,06,\
  74,fb,96,66,81,2f,00,b2,7d,df,57,84,76,67,51,fa,5e,33,5e,36,62,ff,ff,ff,ff,\
  00,00,00,02,00,01,00,02,00,01,00,d3,2d,b2,55,b6,c9,cd,1b,43,8f,e1,1b,50,d0,\
  76,c4,02,00,01,00,02,00,01,00


求助 利用正則 將上面的檔案  分成
@=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\
  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\
這樣的一段   

"SOFT"=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\
  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\
  f4,01,00,00,01,02,00,00,14,02,00,00,00,00,FF,00,00,00,12,00,01,00,00,00,00,\
  00,00,00,FF,25,35,66
這樣一段 字串

"DEBUG"=hex:00,00,00,00,bc,00,00,00,02,00,01,00,bc,00,00,00,1a,00,00,00,00,00,00,\
  00,d8,00,00,00,00,00,00,00,00,00,00,00,d8,00,00,00,18,00,00,00,00,00,00,00,\
  f0,00,00,00,00,00,00,00,00,00,00,00,f0,00,00,00,00,00,00,00,00,00,00,00,f0,\
  00,58,00,03,00,00,00,00,00,14,00,5b,03,02,00,01,01,00,00,00,00,00,01,00,00,\
  00,00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\
  00,00,00,24,00,44,00,02,00,01,05,00,00,00,00,00,05,15,00,00,00,80,cb,af,71,\
  92,18,ec,25,2e,1c,29,2d,f4,01,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,\
  02,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,41,00,64,00,6d,00,\
  69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,18,00,a1,7b,06,\
  74,fb,96,66,81,2f,00,b2,7d,df,57,84,76,67,51,fa,5e,33,5e,36,62,ff,ff,ff,ff,\
  00,00,00,02,00,01,00,02,00,01,00,d3,2d,b2,55,b6,c9,cd,1b,43,8f,e1,1b,50,d0,\
  76,c4,02,00,01,00,02,00,01,00

這樣的一段字串

已知 @  與 "SOFT"  與 "DEBUG" 是固定的  其他內容 是不固定的....
发表于 2014-4-28 08:28:58 | 显示全部楼层
已知 @  與 "SOFT"  與 "DEBUG" 是固定的
可以字符串截取

评分

参与人数 1金钱 +20 收起 理由
kk_lee69 + 20 感謝回復

查看全部评分

 楼主| 发表于 2014-4-28 14:10:50 | 显示全部楼层
回复 2# fuldho

感謝回復  這個是一個方法  只是覺得 想看看正則怎麼做???

我 試著  使用    "SOFT"[\=\w\s][\S\s]*"DEBUG"

可是這樣 只可以抓到  "SOFT" 開始的資料  而且  "DEBUG"  也會跑出來
想把    "DEBUG"  拿掉卻不知道方法 ~~~呵呵

看來正則  真不是 一般人  可以理解的  @@
发表于 2014-4-28 14:38:17 | 显示全部楼层
$sR = StringRegExp($Str, '("SOFT"[\=\w\s][\S\s]*)("DEBUG")',1)
MsgBox(4096, "正则测试" , $sR[0])
发表于 2014-4-28 14:39:47 | 显示全部楼层
本帖最后由 lixiaolong 于 2014-4-28 14:45 编辑

回复 1# kk_lee69

试试这个吧.
#include <Array.au3>

$Str = _
'Windows Registry Editor Version 5.00' & @CRLF & _
'' & @CRLF & _
'[HKEY_LOCAL_MACHINE\SOFTWARE\Canon]' & @CRLF & _
'@=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\' & @CRLF & _
'  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\' & @CRLF & _
'"SOFT"=hex:02,FF,01,25,00,32,00,44,40,05,83,99,41,62,cf,01,00,00,00,00,00,00,00,\' & @CRLF & _
'  00,30,6d,b3,22,bc,9f,cc,01,00,FF,FF,FF,FF,00,00,00,90,71,19,f3,01,a2,cc,01,\' & @CRLF & _
'  f4,01,00,00,01,02,00,00,14,02,00,00,00,00,FF,00,00,00,12,00,01,00,00,00,00,\' & @CRLF & _
'  00,00,00,FF,25,35,66' & @CRLF & _
'"DEBUG"=hex:00,00,00,00,bc,00,00,00,02,00,01,00,bc,00,00,00,1a,00,00,00,00,00,00,\' & @CRLF & _
'  00,d8,00,00,00,00,00,00,00,00,00,00,00,d8,00,00,00,18,00,00,00,00,00,00,00,\' & @CRLF & _
'  f0,00,00,00,00,00,00,00,00,00,00,00,f0,00,00,00,00,00,00,00,00,00,00,00,f0,\' & @CRLF & _
'  00,58,00,03,00,00,00,00,00,14,00,5b,03,02,00,01,01,00,00,00,00,00,01,00,00,\' & @CRLF & _
'  00,00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\' & @CRLF & _
'  00,00,00,24,00,44,00,02,00,01,05,00,00,00,00,00,05,15,00,00,00,80,cb,af,71,\' & @CRLF & _
'  92,18,ec,25,2e,1c,29,2d,f4,01,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,\' & @CRLF & _
'  02,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,41,00,64,00,6d,00,\' & @CRLF & _
'  69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,18,00,a1,7b,06,\' & @CRLF & _
'  74,fb,96,66,81,2f,00,b2,7d,df,57,84,76,67,51,fa,5e,33,5e,36,62,ff,ff,ff,ff,\' & @CRLF & _
'  00,00,00,02,00,01,00,02,00,01,00,d3,2d,b2,55,b6,c9,cd,1b,43,8f,e1,1b,50,d0,\' & @CRLF & _
'  76,c4,02,00,01,00,02,00,01,00'

Local $Test = StringRegExp($Str, '(?s)(?:@|"[^"]+")[^"]+(?:\r|$)', 3)

_ArrayDisplay($Test, UBound($Test))
可能条件变了不管用。
发表于 2014-4-28 15:19:00 | 显示全部楼层
正则真的不是一般人能理解的!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-17 03:03 , Processed in 0.082941 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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