正则表达式查找和替换在语句上构建 SQL(连接)?

问题描述 投票:0回答:1

我正在使用 vscodevim 并且我有

list of variables

我想把它变成

a.list = b.list and a.of = b.of and a.variables = b.variables

用于 SQL 连接。

我使用了查找和替换正则表达式

:s/\w+/a.& = b.& and/g

但显然它会导致

a.list = b.list and a.of = b.of and a.variables = b.variables and

我可以修改正则表达式来删除/跳过最后的

and
而不使用第二个单独的查找和替换吗?

sql regex visual-studio-code vim
1个回答
0
投票

您可以使用

|
作为分隔符来发出多个命令。如果您想在正则表达式的参数中使用
|
,请在其前面加上
\

:s /\w\+/a.& = b.& and/g | s /\s\+and$//g
© www.soinside.com 2019 - 2024. All rights reserved.