manbutianya 发表于 2013-3-29 14:18:29

三段字符,正则表达式,如何提取!

一个iP.txt文件内容如下:
2577180630----abde6760----175.43.12.215
2253543661----abde6760----175.43.12.202
1423265642----abde6760----175.43.12.202
2260235438----abde6760----175.43.12.122
1541165746----abde6760----175.43.12.202
2486652536----abde6760----175.43.12.202
源码如下:
#include <Array.au3>
#include <Inet.au3>
#Include <File.au3>

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;清除文件夹;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Script Start - Add your code below here

; Global function parameters
Local $PublicIP = _GetIP();获取外网IP
$ipfilere = FileRead(@ScriptDir&"\IP.txt")
$ipqqdan = StringRegExp($ipfilere, '\d+--+[^-\r\n]+', 3)

For $t = 0 To UBound($ipqqdan) - 1
        MsgBox(4096, "行数", "共有行数为: " & UBound($ipqqdan) )
        MsgBox(4096, "QQ号码", "QQ12号码为: " & $ipqqdan[$t] )
        $ipqq = StringRegExp($ipqqdan[$t], '[^-]+', 3)
        MsgBox(4096, "QQ号码", "QQ号码为: " & $ipqq )
        MsgBox(4096, "QQ密码", "IP为: " & $ipqq )
        ;MsgBox(4096, "QQ密码", "IP为: " & $ipqq )
       
Next

上段代码只能提取前两段数据,怎么样改成提取三段数据。

manbutianya 发表于 2013-3-29 14:19:54

#include <Array.au3>
#include <Inet.au3>
#Include <File.au3>

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;清除文件夹;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Script Start - Add your code below here

; Global function parameters
Local $PublicIP = _GetIP();获取外网IP
$ipfilere = FileRead(@ScriptDir&"\IP.txt")
$ipqqdan = StringRegExp($ipfilere, '\d+--+[^-\r\n]+', 3)

For $t = 0 To UBound($ipqqdan) - 1
        MsgBox(4096, "QQ号码", "QQ11号码为: " & UBound($ipqqdan) )
        MsgBox(4096, "QQ号码", "QQ12号码为: " & $ipqqdan[$t] )
        $ipqq = StringRegExp($ipqqdan[$t], '[^-]+', 3)
        MsgBox(4096, "QQ号码", "QQ号码为: " & $ipqq )
        MsgBox(4096, "QQ密码", "IP为: " & $ipqq )
        ;MsgBox(4096, "QQ密码", "IP为: " & $ipqq )
       
Next

xms77 发表于 2013-3-30 17:25:45

回复 1# manbutianya

$ipqqdan = StringRegExp($ipfilere, '(?m)(\d+)-+(\w+)-+(.+)', 3)
_arraydisplay($ipqqdan)

mbdnmt 发表于 2013-3-30 23:01:44

额滴个神呀,这样的问题描述你们居然看懂了。。。

haijie1223 发表于 2013-3-30 23:51:46

[^-\n\r]+
页: [1]
查看完整版本: 三段字符,正则表达式,如何提取!