Replace part(s) of string with other char(s)

By Santhosh N

This explains how to replace the part(s) of the string with other string or char

Oracle has a function by the name, REPLACE used to replace the part of the string with other string or character or even remove the specified char(s) from the string.

Syntax: REPLACE( str, str_replace, [ str_toBeReplaced ] )
Here str is the original string and str_replace is the string that needs to be removed and replaced with specified str_toBeReplaced string. If third argument is not passed (which is optional) the string is replaced with empty.

Ex1: REPLACE(‘555egg555’,’555’)
This returns ‘egg’ as the result.

Ex2: REPLACE(‘22EggHead22’, ‘22’, ‘55’)
This returns ‘55EggHead55’ as the result

Ex3: REPLACE(‘ssEggHeadss’, ‘s’)
This returns ‘EggHead’ as the result

Related FAQs

This explains how to convert all the characters to the upper case alphabets
This explains how to convert all the characters to the lower case alphabets
This explains how to find the length of the string in oracle
This explains how to convert first character of the word to the upper case and rest to the lower case.
This explains how to convert one character set strings to other character set strings in oracle. Also, used to convert one data type to other in oracle
Oracle has a function to give the position of the char or string inside the string
Replace part(s) of string with other char(s)  (3464 Views)