Hat*_*kNZ 2 notepad++ regex csv
如何使用带有替换和查找的正则表达式从记事本++中的逗号分隔文件中删除最后一列?
这是我的文件:
2010-09-02,148.67,31.34,0,0,31.34
2010-09-03,149.52,31.24,0,0,31.24
...
Run Code Online (Sandbox Code Playgroud)
我试图在每一行的末尾找到这种模式,基本上是最后一列或最后一个逗号之后的所有内容,例如:
,31.34
,31.34
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所拥有的,但它似乎选择了整行:
.*,\d+.\d+
Run Code Online (Sandbox Code Playgroud)
我只想选择,31.34并删除它,即什么都不替换。
我测试了以下正则表达式,它有效:
搜索:(.+),.+?$
替换为:\1
正则表达式解释道:
(.+),.+?$
( ) = this is a capture group. Its content will be \1, \2, \3 in order of appearance.
.+ = This selects everything greedy mode
, = until it finds the last comma.
(.+), = get everyting except the last , and store it in \1.
.+? = Get everything, non greedy.
$ = until we find the end of the string.
Run Code Online (Sandbox Code Playgroud)
与您问题中的正则表达式不同,只要内容全部
由,.
| 归档时间: |
|
| 查看次数: |
5965 次 |
| 最近记录: |