[已解决]请问如何处理字符串数据,取得二维数组,再直接写入到listview,谢谢.
本帖最后由 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.
正则(?m)^\h*(\S+)\h+(\S+)\h+(\S+)\h+(\S+)整理略 本帖最后由 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)) 有人跟帖后就请不要修改原问题。否则跟帖都会无效成垃圾。有新问题应该跟帖提问。#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, $ix = 0
For $i = 0 To UBound($aSRE) - 4 Step 4
$a2D4[$ix] = $aSRE[$i]
$a2D4[$ix] = $aSRE[$i + 1]
$a2D4[$ix] = $aSRE[$i + 2]
$a2D4[$ix] = $aSRE[$i + 3]
$ix += 1
Next
_ArrayDisplay($a2D4, UBound($a2D4)) 回复 4# afan
知道了, 完美达到要求,非常感谢 不明觉厉....{:face (382):} 不明觉厉!!!
页:
[1]