mIRC在文本文件中搜索多个单词 [英] mIRC Search for multiple words in text file

查看:77
本文介绍了mIRC在文本文件中搜索多个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试搜索文本文件,如果在该行中找到多个单词,该文件将返回结果.我没有在文档中看到这一点,并且尝试了各种循环,但均未成功.

I am trying to search a text file that will return a result if more than one word is found in that line. I don't see this explained in the documentation and I have tried various loops with no success.

我想做的事情与此类似:

What I would like to do is something similar to this:

$read(name.txt, s, word1|word2|word3)

甚至是这样的东西:

$read(name.txt, w, word1*|*word2*|*word3)

我对RegEx不太了解,所以我假设可以做到这一点,但我不知道该怎么做.

I don't know RegEx that well so I'm assuming this can be done with that but I don't know how to do that.

推荐答案

客户端自身中的文档很好,但我也推荐此站点: http://en.wikichip.org/wiki/mirc .对于您的问题,有一篇不错的文章: http://en.wikichip.org/wiki/mirc /text_files

The documentation in the client self is good but I also recommend this site: http://en.wikichip.org/wiki/mirc. And with your problem there is a nice article : http://en.wikichip.org/wiki/mirc/text_files

所有信息均从此处获取.因此要归功于Wikichip.

All the info is taken from there. So credits to wikichip.

alias testForString {
  while ($read(file.txt, nw, *test*, $calc($readn + 1))) {
    var %line = $v1
    ; you can add your own words in the regex, seperate them with a pipe (|)
    noop $regex(%line,/(word1|word2|word3|test)/))
    echo -a Amount of results: $regml(0)
  }
}

$readn是返回与$read()匹配的行的标识符.它用于开始搜索下一行的图案.在这种情况下为test.

$readn is an identifier that returns the line that $read() matched. It is used to start searching for the pattern on the next line. Which is in this case test.

在上面的代码中,$readn从0开始.我们使用$calc()从第1行开始.每个匹配项$read()将在下一行开始搜索.如果在指定的行之后没有更多匹配项,则$read将返回$null-终止循环.

In the code above, $readn starts at 0. We use $calc() to start at line 1. Every match $read() will start searching on the next line. When no more matches are after the line specified $read will return $null - terminating the loop.

w开关用于在搜索中使用通配符

The w switch is used to use a wildcard in your search

n开关可防止像mSL代码一样对所读取的文本进行评估.在几乎每种情况下,您都必须使用n开关.除非您真的需要它.如果不使用$ read()标识符而没有使用'n'开关,则可能会使脚本极易受到攻击.

The n switch prevents evaluating the text it reads as if it was mSL code. In almost EVERY case you must use the n switch. Except if you really need it. Improper use of the $read() identifier without the 'n' switch could leave your script highly vulnerable.

结果存储在名为%line的变量中,以备以后使用.

The result is stored in a variable named %line to use it later in case you need it.

之后,我们使用noop执行正则表达式来满足您的需求.在这种情况下,您可以使用$regml(0)查找在正则表达式搜索中指定的匹配项的 amount .使用if语句,您可以查看是否存在两个或多个匹配项.

After that we use a noop to execute a regex to match your needs. In this case you can use $regml(0) to find the amount of matches which are specified in your regex search. Using an if-statement you can see if there are two or more matches.

希望这对您有所帮助,如果有任何不清楚的地方,我会尽力加以解释.

Hope you find this helpful, if there's anything unclear, I will try to explain it better.

编辑

@ cp022 我无法发表评论,所以我将在此处发表评论,那么这对从文本文件中读取内容有何帮助?

@cp022 I can't comment, so I'll post my comment here, so how does that help in any way to read content from a text file?

这篇关于mIRC在文本文件中搜索多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆