dynamicreplace编辑器中的string

我正在寻找一个解决scheme:我想把特定的文本replace成其他格式的string

防爆。

select * from tab where col like'% ab-de %'=> select * from tab where regexp(col,' ab-de (| $ | \。\ :)')

select* from tab where col like'% 9-01 %'=> select * from tab where regexp(col,' 9-01 (| $ | \。\ :)'

所以在这里,基本上我想要replacestring( ab-de or 9-01 ),无论在% x

=>需要在regexp第二个参数中放置完全相同的string。 ( regexp(col, 'x( |$|\.\: )'

我知道必须有一些方法来完成这一切,但无法弄清楚如何。

在记事本++或Excel或其他编辑器中使用正则expression式或macros

用记事本++:

  • Ctrl + H
  • find: (\w+)\s+like\s+'%(.+?)%'
  • replace为: REGEXP\($1,'$2\( |$|\\.\\:\)'\)
  • 全部replace

注意:括号必须在replace部分中转义

我想你想要( |$|\.|\:)在replace部分,所以:

  • replace为: REGEXP\($1,'$2\([\\ .\\:]|$\)'\)

    做这个工作

说明:

 ( : Start capture group 1 \w+ : 1 or more alphanum or _ (ie. word character) ) : end group \s+ : 1 or more spaces like : literally the word like \s+ : 1 or more spaces ' : literally a single quote % : literally a percent sign ( : Start capture group 2 .+? : 1 or more any character ) : end group % : literally a percent sign ' : literally a single quote 

更换部件:

 REGEXP : literally \( : opening parenthesis $1 : content of group 1, here the name of the column , : a comma '$2' : content of group 2, here what is between % and % , : a comma \( : opening parenthesis [ .:]|$ : literally [ .:]|$, that represent in the resulting regex a space or a dot or a colon or end of line \) : closing parenthesis \) : closing parenthesis