Post

emeditor宏备注

emeditor 最好用的文本编辑器。 没有之一。

有时候解析日志,需要些代码处理,之前一般都是使用python处理的。今天才发现直接使用宏也是很方便的。

这里备注一个宏, 方便处理文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// https://www.emeditor.org/zh-cn/macro/document/getlines.html
// 确认框
//if( confirm( "niss送送送送送s", "woe" ) ) {
//	clipboardData.setData("Text", "hahah");  // copy sum to the Clipboard if 'OK' is clicked
//}

confirm( "emeditor自定义.jar, 自定义插件, 请自己编写处理逻辑!" )
var nLines = document.GetLines( );
var res = ""
	
for(var i=1;i<=nLines ;i++) {
	//confirm( "txt", i )
	l = document.GetLine(i);
	l = parse(l)
	res += l + "\r\n"
}
	
function parse(line) {
	// 这里处理每行数据
	if(line.length > 5) {
		var res1 = JSON.parse(line )	
		return res1['jsonArray'][0]["orderCode"] 
	}
	return line;
}
	
// 复制到剪切板
// clipboardData.setData("Text", res); 
// 消息框
// confirm( "success", "done" )

editor.NewFile();
document.write( res );
This post is licensed under CC BY 4.0 by the author.