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

[系统综合] [已解决]如何用正则提取指定字符?

[复制链接]
发表于 2011-4-8 14:12:07 | 显示全部楼层 |阅读模式
本帖最后由 pdp320921 于 2011-4-12 12:32 编辑
Interface name : Wireless Network Connection 
There are 6 networks currently visible. 

SSID 1 : 802.1_b
    Network type            : Infrastructure
    Authentication          : WPA-Personal
    Encryption              : TKIP 
    BSSID 1                 : 00:0d:bc:68:24:e8
         Signal             : 45%  
         Radio type         : 802.11b
         Channel            : 11 
         Basic rates (Mbps) : 1 2 5.5 11

SSID 2 : WLAN14
    Network type            : Infrastructure
    Authentication          : Open
    Encryption              : None 
    BSSID 1                 : 00:26:0b:15:48:00
         Signal             : 44%  
         Radio type         : 802.11g
         Channel            : 4 
         Basic rates (Mbps) : 11
         Other rates (Mbps) : 12 18 24 36 48 54
    BSSID 2                 : 00:20:a6:4f:2c:f5
         Signal             : 44%  
         Radio type         : 802.11g
         Channel            : 6 
         Basic rates (Mbps) : 1 2 5.5 11
         Other rates (Mbps) : 6 9 12 18 24 36 48 54

SSID 3 : VISITOR
    Network type            : Infrastructure
    Authentication          : Open
    Encryption              : None 
    BSSID 1                 : 00:26:0b:15:48:01
         Signal             : 44%  
         Radio type         : 802.11g
         Channel            : 4 
         Basic rates (Mbps) : 11
         Other rates (Mbps) : 12 18 24 36 48 54

SSID 4 : Guest
    Network type            : Infrastructure
    Authentication          : Open
    Encryption              : WEP 
    BSSID 1                 : 00:26:0b:15:48:02
         Signal             : 45%  
         Radio type         : 802.11g
         Channel            : 4 
         Basic rates (Mbps) : 11
         Other rates (Mbps) : 12 18 24 36 48 54

SSID 5 : sbr3.29
    Network type            : Infrastructure
    Authentication          : Open
    Encryption              : WEP 
    BSSID 1                 : 00:26:cb:94:d7:10
         Signal             : 45%  
         Radio type         : 802.11g
         Channel            : 9 
         Basic rates (Mbps) : 1 2 5.5 11
         Other rates (Mbps) : 6 9 12 18 24 36 48 54

SSID 6 : VISITOR
    Network type            : Infrastructure
    Authentication          : Open
    Encryption              : WEP 
    BSSID 1                 : 00:20:a6:4f:2c:f5
         Signal             : 46%  
         Radio type         : 802.11g
         Channel            : 6 
         Basic rates (Mbps) : 1 2 5.5 11
         Other rates (Mbps) : 6 9 12 18 24 36 48 54
如何运用正则提取SSID返回像下面的数组?
802.1_b
WLAN14
VISITOR
Guest
..........
.........
同上如何运用正则提取Network type,Authentication,Encryption 返回如上面的数组?

求助大虾们~~

PS:首行是空行.上述文本信息框架就那样,顺序有时会变

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-4-8 14:40:02 | 显示全部楼层
本帖最后由 kevinch 于 2011-4-8 14:51 编辑

第一个:
#include <array.au3>

$h_File=FileOpen(@ScriptDir&"\5.txt",0)
$s_Str=FileRead($h_File)
FileClose($h_File)
$a_Arr=StringRegExp($s_Str,"(?:SSID\s?\d+\s?:\s*)([\w.]+)",3)
_ArrayDisplay($a_Arr)
第二个:
#include <array.au3>

$h_File=FileOpen(@ScriptDir&"\5.txt",0)
$s_Str=FileRead($h_File)
FileClose($h_File)
$a_Arr=StringRegExp($s_Str,"(?:Network type\s*:\s*)([\w.]+)",3)
_ArrayDisplay($a_Arr)
第二个的关键字可以替换为其他几个
 楼主| 发表于 2011-4-8 16:34:37 | 显示全部楼层
回复 2# kevinch
非常感谢楼上的解答.
不过使用
StringRegExp($line,"(?:Signal\s*:\s*)([\w.]+)",3)
时百分号丢了~
怎么添加上呢?
 楼主| 发表于 2011-4-8 17:07:37 | 显示全部楼层
StringRegExp($line,"(?:Signal\s*:\s*)([\w.]+\%)",3)
OK了~
发表于 2011-4-8 17:22:38 | 显示全部楼层
这个不太会 跟高手学习了  呵呵
 楼主| 发表于 2011-4-9 13:16:05 | 显示全部楼层
本帖最后由 pdp320921 于 2011-4-9 13:17 编辑


请看上图,请求高手能帮下忙,
如何能做到当BSSID这一列出现非1的数字时,能实现跟上面最近的1的行合并?
如:
上图合并后BSSID这一列成为
BSSID
1,2
1
1
1
1
1
PS:图片中是ListView

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-4-9 14:50:48 | 显示全部楼层
大虾们,请帮下忙啊,在线等啊~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 08:34 , Processed in 0.079148 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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