我突然觉得自己该是有多么的无聊啊。。。。。
例子中是必须姓名完整输入才匹配,按自己需要改那条正则,也可改成StringInStr($file[$i],$name)就只要这一行中有这个字就记录,在一次运行中已经查询过的名字不再重复查询和记录
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include<file.au3>
#include<array.au3>
If Not FileExists("222.txt") Then Exit
Global $file
_FileReadToArray("222.txt", $file)
If Not IsArray($file) Then Exit
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 265, 100, -1, -1)
$Input1 = GUICtrlCreateInput("", 5, 5, 200, 25)
$Edit1 = GUICtrlCreateEdit("", 5, 35, 255, 60, $ES_READONLY)
$Button1 = GUICtrlCreateButton("查询", 210, 5, 50, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $AccelKeys[1][2] = [["{enter}", $Button1]]
GUISetAccelerators($AccelKeys)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_search(GUICtrlRead($Input1))
EndSwitch
WEnd
Func _search($name = "")
GUICtrlSetData($Edit1, "")
If $name <> "" Then
For $i = UBound($file)-1 To 1 Step -1
If StringRegExp($file[$i], $name & '\*\d+', 0) Then;StringInStr($file[$i],$name)
FileWriteLine("ink.txt", $file[$i])
GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & $file[$i] & @CRLF)
_ArrayDelete($file,$i);防止重复记录
EndIf
Next
EndIf
EndFunc ;==>_search
|