Notepad++ 替换第33个逗号后的所有行

Notepad++ 替换第33个逗号后的所有行,notepad++,Notepad++,我在记事本++中打开了一个csv文件。标题有33个逗号,这意味着它有34列。然而,在500k线路中,只有7k线路有33个逗号,其他线路都有更多的逗号。对于每一行,我需要删除后面的所有内容,包括第34个逗号 我用Search:^[^,\n]((,[^,\n]){33}$标识了行 在替换框中,我需要:\1这样的内容来保留找到的字符串,但如何删除其余的字符串 ^[^,\n]*((,[^,\n]*){33}$) 您很接近,只需稍加修改,即可: Ctrl+H 查找内容:^[^,\r\n]*(?:,[^

我在记事本++中打开了一个csv文件。标题有33个逗号,这意味着它有34列。然而,在500k线路中,只有7k线路有33个逗号,其他线路都有更多的逗号。对于每一行,我需要删除后面的所有内容,包括第34个逗号

我用Search:^[^,\n]((,[^,\n]){33}$标识了行

在替换框中,我需要:\1这样的内容来保留找到的字符串,但如何删除其余的字符串

^[^,\n]*((,[^,\n]*){33}$)
您很接近,只需稍加修改,即可:

  • Ctrl+H
  • 查找内容:
    ^[^,\r\n]*(?:,[^,\r\n]*){33}\K.$
  • 替换为:
    留空
  • 检查环绕
  • 检查正则表达式
  • 取消选中
    。匹配换行符
  • 全部替换
说明:

^               # beginning of line
  [^,\r\n]*     # 0 or more any character except comma and linebreak
  (?:           # non capture group
    ,           # a comma
    [^,\r\n]*   # 0 or more any character except comma and linebreak
  ){33}         # end group, appears 33 times
  \K            # forget all we've seen until this position
  .*            # 0 or more any character but newline
$               # end of line