VBScript 在 TXT 中搜索两个字符串
我尝试制作一个VBScript来读取txt并搜索两个字符串并给出仅最后一个结果。
字符串1:Hello123
字符串2:Test123强>
TXT 看起来像这样:
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... Hello123 ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Hello123 ... 'This Result
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Test123 ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Test123 ... 'And this Result
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... BlaBlaBla ...
我尝试这样的事情,但我不知道该怎么做:
我认为使用 ReadALL 读取 txt,而不是搜索部分。
if string 1 not found then
msgbox "nothing found"
Goto NEXT
else
if string 2 not found then
msgbox "nothing found"
else
msgbox "found"
End if
End if
NEXT
有人有想法并且可以帮助我吗?
问候, 马蒂亚斯
i try to make a VBScript that read a txt and search for two strings and gives out only the last results.
String 1: Hello123
String 2: Test123
The TXT looks like this:
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... Hello123 ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Hello123 ... 'This Result
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... BlaBlaBla ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Test123 ...
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... Test123 ... 'And this Result
27.07.2010 09:45 ... DumDumDum ...
27.07.2010 09:45 ... BlaBlaBla ...
I try something like this, but i don't know how to do this:
Read the txt with ReadALL i think and than the search part.
if string 1 not found then
msgbox "nothing found"
Goto NEXT
else
if string 2 not found then
msgbox "nothing found"
else
msgbox "found"
End if
End if
NEXT
Has someone an idea and can help me?
Greetings,
matthias
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它不是更大的 vbscript 程序的一部分,并且您有足够的能力下载东西,您可以使用文件处理工具,例如 gawk for windows 例如一个行
使用 vbscript,使用 instr() 检查每个字符串“Hallo123”和“Test123”,然后如果找到,则为该行分配一个变量。在文件迭代结束时,打印出这两个变量。
搜索“Hallo”的示例
if its not part of a bigger vbscript program and you have the luxury to download stuff, you can use a file processing tool, such as gawk for windows eg one liner
With vbscript, use instr() to check for each string "Hallo123" and "Test123", then if found, assign a variable to that line. At the end of file iteration, print out those 2 variables.
example searching for "Hallo"