0

我以 CSV 格式导出了一些数据,这些数据在文本字段中有一些换行符。我无法让 Excel 正确处理此问题。我只想编辑文件以删除这些换行符。

有效记录以数字开头。我尝试放入\n^([^\d])Notepad++ 的查找/替换的“查找内容”框,以匹配以非数字开头的任何行和前面的换行符。它匹配正确。在“替换为”框中,我放了一个空格,然后用空格\1替换换行符并留下匹配的字符。但是,替换根本不起作用,没有任何改变。

我究竟做错了什么?

示例文本:

123,0,1,"This is a single line comment","bob","jim"
124,0,1,"This is a multi line comment w/ newline.
This is the second line of the comment","ted","alfred"
125,0,1,"This is another single line comment","jim","bob"

我想用空格替换“这是第二个...”之前的换行符,以便文件如下所示:

123,0,1,"This is a single line comment","bob","jim"
124,0,1,"This is a multi line comment w/ newline. This is the second line of the comment","ted","alfred"
125,0,1,"This is another single line comment","jim","bob"
4

2 回答 2

2

我想到了。我曾经(\n)^(?!\d+,\d+)匹配任何换行符,然后是一行的开头,该行的开头没有后跟至少一个数字、一个逗号和至少一个数字。在“替换为”中,我只是放了一个空格。

于 2012-08-28T01:32:12.887 回答
-1

\n如果您将换行设置为 .,则可以在 Notepad++ 中使用Unix (LF)。如果它在 中Windows (CR LF),那么\r\n应该可以工作,或者将返回值转换为 Unix(从底部栏中)。

于 2019-07-26T22:07:05.187 回答