怎么获取txt文件里面的某几个字符
如题:我要获取udo.log里面的OnLastUserInfo - 后面的数字有多少位数udo.log里面的内容如下
2011-05-20 18:01:09.171 -> On ConnectionEstablished
2011-05-20 18:01:09.390 -> CLocalServer::LocalLogin clientVersion 9.1.0.3,3.6.0.59
2011-05-20 18:01:09.546 -> CCommandProcessor - OnLogin
2011-05-20 18:01:10.000 -> Start IProtect Succeed.
2011-05-20 18:01:10.765 -> CCommandProcessor - OnReportAsset
2011-05-20 18:01:11.015 -> CCommandProcessor - OnGetNetbarConfig
2011-05-20 18:01:11.250 -> CFlowControlDlg::OnGetNetbarConfig
2011-05-20 18:01:11.484 -> The WWM Server IP is 192.168.0.252!
2011-05-20 18:01:11.640 -> CCommandProcessor - OnGetClientInfo
2011-05-20 18:01:11.875 -> AutoCheckIn
2011-05-20 18:01:12.125 -> OnLastUserInfo - 0215674275
2011-05-20 18:01:11.531 -> Start IProtect Succeed. $file = FileOpen("udo.log", 0)
; 检查打开的文件是否可读
If $file = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
; 每次读取一行文本,直到文件结束.
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
If StringInStr($line, "OnLastUserInfo") <> 0 Then
$text = StringStripWS($line, 8)
$text = StringSplit($text, "-")
$result = StringLen($text[$text])
MsgBox(0, "字符长度:", $result)
EndIf
Wend
FileClose($file) $Pass = StringRegExp($line,'OnLastUserInfo - (\d+)',3) (?<=-\s)\d+ $file = FileOpen("udo.log")
$str = StringRegExp(FileRead($file), '(?<=OnLastUserInfo\s-\s)\d+', 3)
FileClose($file)
MsgBox(0,"",$str)
页:
[1]