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

[AU3基础] [已解决]请问如何处理字符串数据,取得二维数组,再直接写入到listview,谢谢.

  [复制链接]
发表于 2015-12-25 16:41:18 | 显示全部楼层 |阅读模式
本帖最后由 light_he 于 2015-12-26 19:39 编辑

请问,使用setacl命令得到如下类似字符串,如何将如下字符串里的权限清单处理成二维数组,并写入到listview里
谢谢
e:\file

   DACL(not_protected):
   Administrators   full   allow   container_inherit+object_inherit
   SYSTEM   full   allow   container_inherit+object_inherit
   Administrators   full   allow   no_inheritance
   CREATOR OWNER   full   allow   container_inherit+object_inherit+inherit_only
   Users   read_execute   allow   container_inherit+object_inherit
   Users   FILE_ADD_SUBDIRECTORY   allow   container_inherit
   Users   FILE_ADD_FILE   allow   container_inherit


SetACL finished successfully.
发表于 2015-12-25 18:53:50 | 显示全部楼层
正则
(?m)^\h*(\S+)\h+(\S+)\h+(\S+)\h+(\S+)
整理略
 楼主| 发表于 2015-12-25 21:21:46 | 显示全部楼层
本帖最后由 light_he 于 2015-12-26 09:56 编辑

回复 2# afan

还有一个问题,能不能将数据分成多列,并且如果第一个字串里包含空格,就会有问题
比如  CREATOR OWNER   full   allow   container_inherit+object_inherit+inherit_only
会将CREATOR OWNER 分解成CREATOR和 OWNER
请再帮忙,谢谢。
#include <Array.au3>
Local $sSource = _
                'e:\file' & @CRLF & _
                'DACL(not_protected):' & @CRLF & _
                                'Administrators   full   allow   container_inherit+object_inherit' & @CRLF & _
                                'SYSTEM   full   allow   container_inherit+object_inherit' & @CRLF & _
                                'Administrators   full   allow   no_inheritance' & @CRLF & _
                                'CREATOR OWNER   full   allow   container_inherit+object_inherit+inherit_only' & @CRLF & _
                                'Users   read_execute   allow   container_inherit+object_inherit' & @CRLF & _
                                'Users   FILE_ADD_SUBDIRECTORY   allow   container_inherit' & @CRLF & _
                                'Users   FILE_ADD_FILE   allow   container_inherit' & @CRLF & _
                'SetACL finished successfully.'

Local $aSRE = StringRegExp($sSource, '(?m)^\h*(\S+)\h+(\S+)\h+(\S+)\h+(\S+)', 3)
If Not @Error Then _ArrayDisplay($aSRE, UBound($aSRE))
发表于 2015-12-26 10:15:16 | 显示全部楼层
有人跟帖后就请不要修改原问题。否则跟帖都会无效成垃圾。有新问题应该跟帖提问。
#include <Array.au3>
Local $sSource = _
                'e:\file' & @CRLF & @CRLF & _
                '   DACL(not_protected):' & @CRLF & _
                '   Administrators   full   allow   container_inherit+object_inherit' & @CRLF & _
                '   SYSTEM   full   allow   container_inherit+object_inherit' & @CRLF & _
                '   Administrators   full   allow   no_inheritance' & @CRLF & _
                '   CREATOR OWNER   full   allow   container_inherit+object_inherit+inherit_only' & @CRLF & _
                '   Users   read_execute   allow   container_inherit+object_inherit' & @CRLF & _
                '   Users   FILE_ADD_SUBDIRECTORY   allow   container_inherit' & @CRLF & _
                '   Users   FILE_ADD_FILE   allow   container_inherit' & @CRLF & @CRLF & @CRLF & _
                'SetACL finished successfully.'
;~MsgBox(0, '源字符串', $sSource)
Local $aSRE = StringRegExp($sSource, '(?m)^\h*([\S\h]+)\h+(\S+)\h+(\S+)\h+(\S+)', 3)
If @Error Then Exit
Local $i, $a2D4[UBound($aSRE) / 4][4], $ix = 0
For $i = 0 To UBound($aSRE) - 4 Step 4
        $a2D4[$ix][0] = $aSRE[$i]
        $a2D4[$ix][1] = $aSRE[$i + 1]
        $a2D4[$ix][2] = $aSRE[$i + 2]
        $a2D4[$ix][3] = $aSRE[$i + 3]
        $ix += 1
Next
_ArrayDisplay($a2D4, UBound($a2D4))
 楼主| 发表于 2015-12-26 10:32:35 | 显示全部楼层
回复 4# afan


   知道了, 完美达到要求,非常感谢
发表于 2016-3-16 20:30:34 | 显示全部楼层
不明觉厉....
发表于 2016-5-27 23:47:08 | 显示全部楼层
不明觉厉!!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 06:09 , Processed in 0.084835 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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