求解电脑名正则(急)
想了一天一夜了。没有满意的效果IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
192.168.0.54 THWB-JK <unknown> 00-19-db-6c-22-e9
192.168.0.63 A063 <unknown> 00-19-db-6c-95-20
192.168.0.244 XIAOYU-T23 <unknown> 00-02-2d-6f-dd-52
192.168.0.246 THWB-SEC <server><unknown> 00-1b-fc-3b-f6-8c
192.168.0.248 THWB-PRI <server><unknown> 00-0e-0c-dd-1a-01
192.168.0.249 SOSHU <server><unknown> 00-e0-81-4a-00-55
192.168.0.252 SERVER-FILE <server><unknown> 00-18-f3-a8-8c-14
192.168.0.253 ZZWLINE <server><unknown> 00-0e-0c-dd-1a-06
192.168.0.245 THWB-JKJ <server><unknown> 00-1b-fc-4b-7c-4a
192.168.0.247 JUJUMAO <unknown> 00-01-6c-03-3b-9b
求把里面的电脑名取出来的正则
我现在写的是
\w{4}\s{14}
但这样只能提取一部分。实在是头痛。高人帮解!!:face (23):
[ 本帖最后由 mexiaoyuoo 于 2008-12-11 20:27 编辑 ] (?<=\s)\w+(-\w+)*(?=\s) 原帖由 pcbar 于 2008-12-11 17:39 发表 http://www.autoitx.com/images/common/back.gif
(?
好像不对
取出来的数组是
= NBT
= name
= scan
= for
= addresses
= from
= IP
= address
= NetBIOS
= Name
= Server
= User
= MAC
= address
= -JK
= -e9
= A063
= -20
= -T23
= -52
= -SEC
= -8c
= -PRI
= -01
= SOSHU
= -55
= -FILE
= -14
= ZZWLINE
= -06
= -JKJ
= -4a
= JUJUMAO
= -9b
我想要的是取出
NetBIOS Name 那一列的电脑名 我现在使用这个正则
\s{1,15}\s
能取出如下
=NBT
=scan
=addresses
=
IP
=NetBIOS
=Server
=User
=MAC
=THWB-JK
=A063
=XIAOYU-T23
=THWB-SEC
=THWB-PRI
=SOSHU
=SERVER-FILE
=ZZWLINE
=THWB-JKJ
=JUJUMAO
但前面的
=NBT
=scan
=addresses
=
IP
=NetBIOS
=Server
=User
=MAC
不是电脑名
如何排除:face (13): 这里完全可以不用什么正则。哪来的这么麻烦。
直接字符串分割还快。以前我就写过这个工具的提取代码。 原帖由 sanhen 于 2008-12-11 18:13 发表 http://www.autoitx.com/images/common/back.gif
这里完全可以不用什么正则。哪来的这么麻烦。
直接字符串分割还快。以前我就写过这个工具的提取代码。
:face (37): 有无示例. 不会正则,用字符串函数也可以做到,
$file = FileOpen("test.txt", 0)
$file1 = FileOpen("test1.txt", 1+8)
If $file = -1 OR $file1 = -1Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
if StringInStr($line,"192.168.") Then
FileWriteLine($file1, StringStripWS(StringMid($line, 18, StringInStr($line,"<")-18) ,1+2))
EndIf
Wend
FileClose($file)
FileClose($file1) 用linux方法,输入到文本,awk,以空格为分隔符,取第二列的 匹配IP
$ip = StringRegExp($a, '((2\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)', 4)
匹配mac
$mac = StringRegExp($a, '(\w{2}-\w{2}-\w{2}-\w{2}-\w{2}-\w{2})', 3)
页:
[1]