我正在读取文件中的数据,所以下面的代码将奇异线数据推送到results
如何在下面的情况下根据ID拆分数据ID
。目标是获取该ID甚至是多行的完整数据。如何根据ID分割数据?
Ctrl.js
var results = [];
var lines = data.split('\n'); // get the lines
lines.forEach(function(line) { // for each line in lines
if (line.indexOf(searchStr) != -1) { // if the line contain the searchSt
results.push({
filename:logfile.filename,
value:line
});
}
});
file.txt的
[ID:81d166ed-dcd6-4f30-bcf4-7c3c1a8feefb]testid Lorem test Ipsum is simply dummy text text of the printing and typesetting ind
[ID:8a3b2de6-742e-49e4-bf96-02d14e6b0799]testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry.
[ID:c3d19dfe-d803-4661-a0c4-52a18aa48766]testid Lorem test Ipsum is simply dummy
是什么'searchStr'值? – RomanPerekhrest
基本上它的搜索功能,所以'searchStr'是客户端的用户输入,我们必须匹配来自文件的数据并发送该事件的完整数据 – hussain
不清楚。 *我如何分割数据基于ID *。应该如何看待预期的结果? – RomanPerekhrest