本帖最后由 骗子 于 2016-7-28 16:14 编辑
批量将类似 '10:1B:54:21:C8:94'的MAC地址修改为 '101B:-5421-C894'
目前想法就是先把源数据按行读取,然后对于每一行进行处理,然后在合到一起
下面的是我针对单个的转换,感觉太啰嗦,求个简单效率的方法,谢谢各位
$mac = '10:1B:54:21:C8:94'
$mac = StringRegExpReplace($mac, ':', '', 1)
$mac = StringRegExpReplace($mac, ':', '-', 1)
$mac = StringRegExpReplace($mac, ':', '', 1)
$mac = StringRegExpReplace($mac, ':', '-', 1)
$mac = StringRegExpReplace($mac, ':', '', 1)
MsgBox(0, 0, $mac)
第二个方法,感觉也没好到哪里去
$mac = '10:1B:54:21:C8:94'
For $t = 0 To 4
If Mod($t, 2) = 0 Then
$mac = StringRegExpReplace($mac, ':', '', 1)
Else
$mac = StringRegExpReplace($mac, ':', '-', 1)
EndIf
Next
MsgBox(0, 0, $mac)
第3、4种方法,看上去简单多了
#include <Array.au3>
$mac = '10:0B:04:21:08:94'
$a = StringSplit($mac, ":", 2)
If UBound($a) = 6 Then $m = $a[0] & $a[1] & "-" & $a[2] & $a[3] & "-" & $a[4] & $a[5]
$a = StringRegExp($mac, '\w{2}', 3)
If UBound($a) = 6 Then $n = $a[0] & $a[1] & "-" & $a[2] & $a[3] & "-" & $a[4] & $a[5]
MsgBox(0, 0, $mac & @CRLF & $m & @CRLF & $n)
|