我正在讀取文件中的數據,所以下面的代碼將奇異線數據推送到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