Oracle - PL/SQL - REPLACE Function

In Oracle/PLSQL, the replace function replaces a sequence of characters in a string with another set of characters.

The syntax for the replace function is:

replace( string1, string_to_replace, [ replacement_string ] )

string1 is the string to replace a sequence of characters with another set of characters.

string_to_replace is the string that will be searched for in string1.

replacement_string is optional. All occurrences of string_to_replace will be replaced with replacement_string in string1. If the replacement_string parameter is omitted, the replace function simply removes all occurrences of string_to_replace, and returns the resulting string.

Applies To:

· Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

For example:

replace('123123oracle', '123');

would return 'oracle'

replace('123oracle123', '123');

would return 'oracle'

replace('222oracle', '2', '3');

would return '333oracle'