开发者

Regular expression to remove the last column from a pipe delimited file

I've got a file with 1000's of entries and 131 columns, the columns are pipe delimited. There is no pipe at the end so format i开发者_如何学Pythons something like.

2010-10-04|Security|AMEND|20162214| ... lots more columns ... |Bloomberg

How can I remove the last column of the file say in Vim ?


Tou need

%s/|[^|]*$// 

Note I am using [^|]* to allow for an empty column.


This regular expression will catch the last column: \|[^|]+$


Another way:

:%s/.*\zs|.*//


I would just use cut, or awk at a push

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜