This Oracle tutorial explains how to use the Oracle/PLSQL REPLACE function with syntax and examples.
The Oracle/PLSQL REPLACE function replaces a sequence of characters in a string with another set of characters.
The syntax for the REPLACE function in Oracle/PLSQL is:
REPLACE( string1, string_to_replace [, replacement_string] )
The string to replace a sequence of characters with another set of characters.
The string that will be searched for in string1.
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.
The REPLACE function returns a string value.
The REPLACE function can be used in the following versions of Oracle/PLSQL:
Let's look at some Oracle REPLACE function examples and explore how to use the REPLACE function in Oracle/PLSQL.
For example:
REPLACE('123123aodb', '123');
Output: 'aodb'
REPLACE('123aodb123', '123');
Output:'aodb'
REPLACE('222aodb', '2', '3');
Output: '333aodb'
REPLACE('0000123', '0');
Output: '123'
REPLACE('0000123', '0', ' ');
Output: ' 123'