2

vim 正则表达式替换

 2 years ago
source link: https://www.v2ex.com/t/803602
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

vim 正则表达式替换

  silenceboychen · 18 小时 58 分钟前 · 656 次点击

有一批类似这样的数据:

('526440130559344640','2',7,to_date('2020-11-18 00:00:00','yyyy-mm-dd hh24:mi:ss'),'0',null,null,to_date('2020-11-26 01:48:39.705','yyyy-mm-dd hh24:mi:ss')),
('526440158212390912','2',3,to_date('2020-11-18 00:00:00','yyyy-mm-dd hh24:mi:ss'),'0',null,null,to_date('2020-11-26 01:48:39.705','yyyy-mm-dd hh24:mi:ss')),

如何使用正则表达式批量将里边的 to_date 这一段,

to_date('2020-11-26 01:48:39.705','yyyy-mm-dd hh24:mi:ss')

提取出里边的日期,并替换掉这一段内容

to_date('2020-11-26 01:48:39.705','yyyy-mm-dd hh24:mi:ss')  =>  '2020-11-26 01:48:39.705'

最终数据变为下边的格式

('526440130559344640','2',7,'2020-11-18 00:00:00','0',null,null,'2020-11-26 01:48:39.705'),('526440158212390912','2',3,'2020-11-18 00:00:00','0',null,null,'2020-11-26 01:48:39.705'),

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK