我想要的文本块添加到输出文件,使用:如何使用范围(..)运算符查找从“字符串”到“ n n”的行?
File.foreach("#{options[:source]}") do |li|
if (li['Exception:'] .. li["\n\n"]) then
bufferBlocks.push(li)
end
end
一个例子的例外可能是:
#^^ log continues prior to this ^^
words .. words .. words
words .. words .. words
words .. words .. words
words .. words .. words
Exception: ERROR 50001
File: source.cpp
Line: 221
Msg: Encountered unknown server error!
words .. words .. words
words .. words .. words
words .. words .. words
#\/ log continues below this \/
和所有我想在我的输出是块:
Exception: ERROR 50001
File: source.cpp
Line: 221
Msg: Encountered unknown server error!
你介意解释这是如何工作的吗? – MrDuk
其在红宝石和扫描日志文件中的被称为触发器是少数几个地方你会用红宝石触发器 – bjhaid
我给我的答案添加了一个解释。 –