本帖最后由 redapple2008 于 2024-5-30 10:05 编辑
我只需要mac地址,如“51:7B:1D:46:09:88”这一部份,正则怎么处理?
; 正则匹配测试
#include <Array.au3>
Local $sInput = _
"[计算机名]" & @CRLF & _
"计算机名=CLIENT7" & @CRLF & _
"[51:7B:1D:46:09:88]" & @CRLF & _
"IP=10.9.8.7" & @CRLF & _
"子网掩码=255.255.0.0" & @CRLF & _
"网关=10.9.8.254" & @CRLF & _
"首选DNS=10.9.3.22" & @CRLF & _
"[00:50:56:C0:00:01]" & @CRLF & _
"IP=169.254.208.88" & @CRLF & _
"子网掩码=255.255.0.0" & @CRLF & _
"网关=" & @CRLF & _
"首选DNS=" & @CRLF & _
"备用DNS=" & @CRLF & _
"[00:50:56:C0:00:08]" & @CRLF & _
"IP=192.168.208.88" & @CRLF & _
"子网掩码=255.255.0.0" & @CRLF & _
"网关=" & @CRLF & _
"首选DNS=" & @CRLF & _
"备用DNS=" & @CRLF & _
""
;MsgBox(262144, "源字符串", $sInput)
Local $aRegExp = StringRegExp($sInput, "([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}", 4)
_ArrayDisplay ($aRegExp)
Local $aMatch = 0
For $i = 0 To UBound($aRegExp) - 1
$aMatch = $aRegExp[$i]
For $j = 0 To UBound($aMatch) - 1
MsgBox(Default, "RegExp 测试: [" & $i & "] >> " & "[0]", $aMatch[$j])
Next
Next
|