我的文本文件中有大量数据,这给我带来了一些问题。文件中的许多记录之间都有换行符。例如,这就是我当前的数据:
30670169, Corvette, EL-P078675, EL-P078675, Chevrolet Corvette C6 Color Matching Millenium Yellow License Plate Frame, "Made from high-quality billet aluminum, this stylish license frame is custom painted to precisely match the color of your C6 Corvette.
It features an engraved OEM style nameplate. High-gloss finished will never rust.
12"" x 6"" in standard size. Includes color matched screw covers and hardware.
This is a special custom made item. It takes 10-15 business days to ship.
Brand new official licensed product."
应该这样读:
30670169, Corvette, EL-P078675, EL-P078675, Chevrolet Corvette C6 Color Matching Millenium Yellow License Plate Frame, "Made from high-quality billet aluminum, this stylish license frame is custom painted to precisely match the color of your C6 Corvette. It features an engraved OEM style nameplate. High-gloss finished will never rust. 12"" x 6"" in standard size. Includes color matched screw covers and hardware. This is a special custom made item. It takes 10-15 business days to ship. Brand new official licensed product."
我需要一种方法来删除换行符(仅当换行符被引号包围时)。大家有什么想法吗?
最佳答案
尝试使用Notepad++的查找/替换功能。
查找:
\r(?!\n)
替换为:
(空格)
您需要选中正则表达式复选框:
先尝试替换几行(例如选择前 80 行),然后替换选择内容以查看。如果有效,您可以继续处理整个文件。
上面的 \r
将匹配 CR,\n
将匹配 LF。 (?!\n)
是一个特殊组,表示“如果后跟 \n
,则不匹配 \r
”。
注意:我认为 notepad++ 有时无法正确执行替换,因此如果一次替换整个文件会导致问题,请尝试小批量替换。
我通常使用脚本来做这样的事情,但如果您不习惯的话,我认为您不会准备好使用脚本:s
关于excel - 仅当引号引起来时才删除换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22947602/