如何在Notepad ++中编写正则表达式,用逗号搜索和替换所有空格(最多到某一点)?
原始文字
468620438 [2012-07-07 00:00:00,307] [Thread-20] INFO BIZ,Handler,getJobs():Retrieving messages from A...
468620438 [2012-07-07 00:00:00,307] [Thread-20] INFO BIZ,InterfaceAdaptor,getMessages : Retrieving messages from B
468620453 [2012-07-07 00:00:00,322] [Thread-20] INFO BIZ,Handler,_getNextMessage():Retrieving messages from B
修订文本
468620438,[2012-07-07 00:00:00,307],[Thread-20],INFO,BIZ,Handler,getJobs():Retrieving messages from A...
468620438,[2012-07-07 00:00:00,307],[Thread-20],INFO,BIZ,InterfaceAdaptor,getMessages : Retrieving messages from B
468620453,[2012-07-07 00:00:00,322],[Thread-20],INFO,BIZ,Handler,_getNextMessage():Retrieving messages from B
答案 0 :(得分:1)
最简单的方法是准确说明您想要替换的内容:
替换
^(\S+)\s+(\S+\s+\S+)\s+(\S+)\s+(\S+)\s+
通过
\1,\2,\3,\4
这是最简单的,因为您需要包含字段外观的知识,从而使事情变得复杂,例如:第二列包含一个 not 替换的空格。