![Notepad++ 合并所有不以日期开头的行](https://linux22.com/image/1562808/Notepad%2B%2B%20%E5%90%88%E5%B9%B6%E6%89%80%E6%9C%89%E4%B8%8D%E4%BB%A5%E6%97%A5%E6%9C%9F%E5%BC%80%E5%A4%B4%E7%9A%84%E8%A1%8C.png)
我 .csv
在 Notepad++ 中有一个文件,其中包含如下数据:
1-6-2018,"(101)","","Sale",-862.96,,
"(Sale)",,837.96,
,"Diesel",12.000 Ltr,69.83/Ltr,837.96,
"Sales @ 5%",,23.80,
,"Polishing Cloth",1 Pcs,23.80/Pcs,23.80,
"CGST @ 2.5%",,0.60,
"SGST @ 2.5%",,0.60,
"(No. :16532)",
1-6-2018,"(149)","","Sale",-3212.18,,
"Sales(Sale)",,3212.18,
,"Diesel",46.000 Ltr,69.83/Ltr,3212.18,
"(No. :16533)",
// and many more
如何在 Notepad++ 中使用搜索和替换(或任何其他方法)来合并所有不以日期开头的行,以便最终结果看起来像这样?
1-6-2018,"(101)","","Sale",-862.96,,"(Sale)",,837.96,,"Diesel",12.000 Ltr,69.83/Ltr,837.96,"Sales @ 5%",,23.80,,"Polishing Cloth",1 Pcs,23.80/Pcs,23.80,"CGST @ 2.5%",,0.60,"SGST @ 2.5%",,0.60,"(No. :16532)",
1-6-2018,"(149)","","Sale",-3212.18,,"(Sale)",,3212.18,,"Diesel",46.000 Ltr,69.83/Ltr,3212.18,"(No. :16533)",
每行不以日期开头的行都会与前一行合并......
答案1
- Ctrl+H
- 找什么:
\R(?!\d{1,2}-\d{1,2}-\d{4})
- 用。。。来代替:
LEAVE EMPTY
- 检查环绕
- 检查正则表达式
- Replace all
解释:
\R : any kind of linebreak
(?! : start negative look ahead, make sure we don't have after:
\d{1,2} : 1 or 2 digits
- : a dash
\d{1,2} : 1 or 2 digits
- : a dash
\d{4} : 4 digits
) : end lookahead (ie. a date)
给定示例的结果:
1-6-2018,"(101)","","Sale",-862.96,,"(Sale)",,837.96,,"Diesel",12.000 Ltr,69.83/Ltr,837.96,"Sales @ 5%",,23.80,,"Polishing Cloth",1 Pcs,23.80/Pcs,23.80,"CGST @ 2.5%",,0.60,"SGST @ 2.5%",,0.60,"(No. :16532)",
1-6-2018,"(149)","","Sale",-3212.18,,"Sales(Sale)",,3212.18,,"Diesel",46.000 Ltr,69.83/Ltr,3212.18,"(No. :16533)",