-1

如何在 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
4

1 回答 1

1

最简单的方法是准确说明您要替换的内容:

代替

^(\S+)\s+(\S+\s+\S+)\s+(\S+)\s+(\S+)\s+

经过

\1,\2,\3,\4

这是最简单的,因为您需要包含字段外观的知识,从而使事情复杂化,例如,第二列包含不应替换的空格

于 2012-07-11T10:10:46.720 回答