1
@text = 'First +Last /(toto salary *0.07)'

什么是在运算符之间替换“仅整个短语”的 SQL 查询

我是说 :

  replace(@text , 'toto salary','bobo salary')
  result : 'First +Last /(bobo salary *0.07)'

但当 :

replace(@text , 'toto','') 
NO result because not match whole phrase ('toto salary')

换句话说,替换'* + / - ()'运算符之间的短语

4

1 回答 1

0

以下可以工作:

select regexp_replace( 'First +Last /(toto salary *0.07)' , '(/\()toto salary( [*][0-9]+[.]?[0-9]*\))','\1bobo salary\2') from dual;

诀窍是在要保留的强制部分周围加上括号,在这种情况下是 the/(和 the *0.07),然后通过在替换表达式中添加\1等来包含这些部分。\2

于 2013-04-24T09:37:05.997 回答