问个查询文本内容的问题
6/1/2011 8:56:9 - PFRO Error: \??\C:\Users\Administrator\AppData\Roaming\Tencent\QQ\AUTemp\L(2T]}%BH7%I09CDJV@V0B1\1305880992493657663, |delete operation|, 0xc00001016/1/2011 8:56:9 - 8 Successful PFRO operations
6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\12074065\, |delete operation|, 0xc0000101
6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4f7aec4d\, |delete operation|, 0xc0000101
6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\5f7adcac\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\9194849a\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dee01ee0\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4e68af1b\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\829fb9ce\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dd63124c\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\801dbe41\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\821fb8ef\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\cde02309\, |delete operation|, 0xc0000101
6/4/2011 9:6:9 - 1 Successful PFRO operations
6/5/2011 10:2:53 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101
6/5/2011 10:2:54 - 141 Successful PFRO operations
6/28/2011 9:21:37 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101
6/28/2011 9:21:37 - 141 Successful PFRO operations上面是一个文本文件的内容,想得到包含“0xc0000101”的行数,应该怎么做 #include <Array.au3>
Local $Str = _
'6/1/2011 8:56:9 - PFRO Error: \??\C:\Users\Administrator\AppData\Roaming\Tencent\QQ\AUTemp\L(2T]}%BH7%I09CDJV@V0B1\1305880992493657663, |delete operation|, 0xc0000101' & @CRLF & _
'6/1/2011 8:56:9 - 8 Successful PFRO operations' & @CRLF & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\12074065\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4f7aec4d\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\5f7adcac\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\9194849a\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dee01ee0\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4e68af1b\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\829fb9ce\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dd63124c\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\801dbe41\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\821fb8ef\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\cde02309\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - 1 Successful PFRO operations' & @CRLF & @CRLF & _
'6/5/2011 10:2:53 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101' & @CRLF & _
'6/5/2011 10:2:54 - 141 Successful PFRO operations' & @CRLF & @CRLF & _
'6/28/2011 9:21:37 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101' & @CRLF & _
'6/28/2011 9:21:37 - 141 Successful PFRO operations' & @CRLF & _
'这一行是增加的,测试匹配不仅仅是行尾6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\cde02309\, |delete operation|, 0xc0000101 这里增加了测试'
MsgBox(0, '原字符串', $Str)
;Local $Test = StringRegExp($str, '(?m)^.*?0x+', 3);如果要匹配包含所有16进制的行时用这句
;Local $Test = StringRegExp($str, '(?m)^.*?0xc0000101(?=[\r\n])', 3);如果0xc0000101必须在行尾才匹配的话用这句
Local $Test = StringRegExp($str, '(?m)^.*?0xc0000101(?(?![\r\n]).*)', 3);如果0xc0000101在行中间也匹配的话用这句
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($Test), '其中元素为: ' & $Test)
_ArrayDisplay($Test, UBound($Test)) 3maile,学习了 同样受教极多! 非常感谢3mile 本帖最后由 netegg 于 2011-7-11 07:31 编辑
行数还是行号,如果是文本,大可以不用正则
_filereadtoarray()
$aIndex = _arrayfindall() -----这是所有的行号
msgbox(0,0,ubound($aIndex)) -----这是行数
如果文本很大,还是用正则吧,array可能要受限制 3mile哥威武。。。 本帖最后由 shenrenba 于 2011-7-11 11:00 编辑
另一种方法
Local $Str = _
'6/1/2011 8:56:9 - PFRO Error: \??\C:\Users\Administrator\AppData\Roaming\Tencent\QQ\AUTemp\L(2T]}%BH7%I09CDJV@V0B1\1305880992493657663, |delete operation|, 0xc0000101' & @CRLF & _
'6/1/2011 8:56:9 - 8 Successful PFRO operations' & @CRLF & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\12074065\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4f7aec4d\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:8 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\5f7adcac\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\9194849a\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dee01ee0\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\4e68af1b\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\829fb9ce\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Program Files (x86)\Common Files\Tencent\QQPhotoDrawEx\QQPhotoDrawEx.2.27.171.429.dll, |delete operation|, 0xc0000034' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\dd63124c\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\801dbe41\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\821fb8ef\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\cde02309\, |delete operation|, 0xc0000101' & @CRLF & _
'6/4/2011 9:6:9 - 1 Successful PFRO operations' & @CRLF & @CRLF & _
'6/5/2011 10:2:53 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101' & @CRLF & _
'6/5/2011 10:2:54 - 141 Successful PFRO operations' & @CRLF & @CRLF & _
'6/28/2011 9:21:37 - PFRO Error: \??\C:\ProgramData\Tencent\QQPinyin\Repair\, |delete operation|, 0xc0000101' & @CRLF & _
'6/28/2011 9:21:37 - 141 Successful PFRO operations' & @CRLF & _
'这一行是增加的,测试匹配不仅仅是行尾6/4/2011 9:6:9 - PFRO Error: \??\C:\Users\ADMINI~1\AppData\Local\Temp\VMwareDnD\cde02309\, |delete operation|, 0xc0000101 这里增加了测试'
;上面这是3M的内容 我直接复制的
If StringRegExpReplace($str, '(?i).+?0xc0000101(?:\r\n|$)',"") Then MsgBox(0,0,@extended) 太复杂了,但是用到
页:
[1]