Abhishek
Abhishek

Reputation: 33

Oracle SQL regular expression replacement

I have an Employees table where I have columns such as last_name first_name,salary, etc.. I want to write a query which will replace

for each last_name in the Employees table. Basically there are two ways to do it

  1. translate: if I use this I am missing out either on lower case or upper case matching,e.g. translate(last_name,[skae],[kaes])

  2. regexp_replace: I tried this, but from second replacement it is replacing the character with null. regexp_replace(last_name,'[(s|S)(k|K)(a|A)(e|E)]',[KAES],1,0,'i']

Upvotes: 0

Views: 47

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269973

Use translate() for single character replacement:

select translate(last_name, 'SsKkAaEs', 'KKAAEESS')

Upvotes: 3

Related Questions