fuldho 发表于 2014-5-24 08:51:32

求正则<已解决>

本帖最后由 fuldho 于 2014-5-27 07:50 编辑

#include <Array.au3>
$Str="(FOLDER) C:\Program Files\Common Files\Thunder Network\ServicePlatform" & @CRLF & _
       "(*)(FILE) stat.xml" & @CRLF & _
      "2014/5/23 17:13, 8 bytes, A ==> 2014/5/23 17:14, 8 bytes, A" & @CRLF & _
    "(FOLDER) C:\Program Files\TAP-Windows" & @CRLF & _
       "(*)(FILE) Uninstall.exe" & @CRLF & _
      "2014/5/23 17:12, 83823 bytes, A ==> 2014/5/23 17:14, 83823 bytes, A" & @CRLF & _
    "(FOLDER) C:\Users\Administrator\AppData\Roaming\Tencent\Logs" & @CRLF & _
       "(*)(FILE) QQ.tlg" & @CRLF & _
      "2014/5/23 16:58, 11309816 bytes, A ==> 2014/5/23 17:13, 11619124 bytes, A" & @CRLF & _
    "(FOLDER) C:\Windows\inf" & @CRLF & _
       "(+)(FILE) oem9.inf = 2014/5/23 17:14, 7271 bytes, A" & @CRLF & _
       "(+)(FILE) oem9.PNF = 2014/5/23 17:14, 8304 bytes, A" & @CRLF & _
       "(*)(FILE) setupapi.dev.log" & @CRLF & _
       " 2014/5/23 17:12, 2839343 bytes, A ==> 2014/5/23 17:14, 2917412 bytes, A" & @CRLF & _
       "(*)(FILE) setupapi.ev1" & @CRLF & _
       " 2014/5/23 17:12, 6240 bytes, A ==> 2014/5/23 17:14, 6296 bytes, A" & @CRLF & _
       "(*)(FILE) setupapi.ev2" & @CRLF & _
       " 2014/1/4 15:36, 7416 bytes, A ==> 2014/5/23 17:14, 7448 bytes, A" & @CRLF & _
       "(*)(FILE) setupapi.ev3" & @CRLF & _
      "2014/5/23 17:12, 86016 bytes, A ==> 2014/5/23 17:14, 86016 bytes, A" & @CRLF & _
    "(FOLDER) C:\Windows\System32\catroot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}" & @CRLF & _
       "(+)(FILE) oem9.CAT = 2013/8/22 20:40, 10476 bytes, S" & @CRLF & _
    "(FOLDER) C:\Windows\System32\drivers" & @CRLF & _
      " (+)(FILE) tap0901.sys = 2013/8/22 20:40, 35288 bytes, A" & @CRLF & _
    "(FOLDER) C:\Windows\System32\DriverStore" & @CRLF & _
      " (*)(FILE) INFCACHE.1" & @CRLF & _
      "2014/1/4 15:36, 1539176 bytes, A ==> 2014/5/23 17:14, 1539288 bytes, A" & @CRLF & _
      " (*)(FILE) infpub.dat" & @CRLF & _
      "2014/1/4 15:36, 86016 bytes, A ==> 2014/5/23 17:14, 86016 bytes, A" & @CRLF & _
      " (*)(FILE) infstor.dat" & @CRLF & _
      "2014/1/4 15:36, 143360 bytes, A ==> 2014/5/23 17:14, 143360 bytes, A" & @CRLF & _
      " (*)(FILE) infstrng.dat" & @CRLF & _
   "   2014/1/4 15:36, 143360 bytes, A ==> 2014/5/23 17:14, 143360 bytes, A" & @CRLF & _
    "(+)(FOLDER) C:\Windows\System32\DriverStore\FileRepository\oemwin2k.inf_x86_neutral_4a65d8f20107343c" & @CRLF & _
      " (+)(FILE) oemwin2k.inf = 2013/8/22 19:38, 7271 bytes, A" & @CRLF & _
   "(+)(FILE) oemwin2k.PNF = 2014/5/23 17:14, 8304 bytes, A" & @CRLF & _
      " (+)(FILE) tap0901.cat = 2013/8/22 20:40, 10476 bytes, A" & @CRLF & _
      " (+)(FILE) tap0901.sys = 2013/8/22 20:40, 35288 bytes, A"


$nstr1 = StringRegExp($str, "\(FOLDER\)(.*?)\r", 3)
_ArrayDisplay($nstr1)
$nstr2 = StringRegExp($str, "\(FILE\)(.*?)=", 3)
_ArrayDisplay($nstr2)

把每个文件夹FOLDER下的文件匹配到该文件夹下
如第一个FOLDER
C:\Program Files\Common Files\Thunder Network\ServicePlatform\stat.xml

C:\Program Files\Common Files\Thunder Network\ServicePlatform
stat.xml
最后一个FOLDER
C:\Windows\System32\DriverStore\FileRepository\oemwin2k.inf_x86_neutral_4a65d8f20107343c\oemwin2k.inf

C:\Windows\System32\DriverStore\FileRepository\oemwin2k.inf_x86_neutral_4a65d8f20107343c\oemwin2k.PNF
....

先谢谢了

afan 发表于 2014-5-24 15:32:55

试下StringRegExpReplace($str, '(?mi)^\h*[\d/:\h]+,.+?>\V+\v+|\h*=\h*[\d/:\h]+,\h*\d+\h*bytes,\V+|^\h*(?:\([*+]\))?\((?:FOLDER|FILE)\)\h+', '')剔干净后按需使用

haijie1223 发表于 2014-5-25 13:18:47

回复 2# afan


    A版,我表示没有看懂题目~您竟然明白了~

fuldho 发表于 2014-5-27 07:41:53

本帖最后由 fuldho 于 2014-5-27 07:51 编辑

回复 2# afan

非常感谢 afan 版主,
替换方法,厉害!
二次整理就可以了

东风破 发表于 2014-5-27 09:03:37

回复 3# haijie1223


    同感,表示也没看懂题目。不过,为啥A大的正则每次都那么长,那么销魂。。。

ak47gglllk 发表于 2014-5-27 09:16:59

还看不懂,小菜鸟路过,感谢各位大大支持、
页: [1]
查看完整版本: 求正则<已解决>