Search This Blog

Wednesday 10 February 2016

Oracle DB: REPLACE Function

DESCRIPTION

The Oracle REPLACE function replaces a sequence of characters in a string with another set of characters.

SYNTAX

REPLACE( string1, string_to_replace, replacement_string )

PARAMETERS or ARGUMENTS

string1 - The string to replace a sequence of characters with another set of characters.

string_to_replace - The string that will be searched for in string1.

replacement_string – This parameter 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.

EXAMPLES

REPLACE('123123test', '12');    
     Result: '33test'
REPLACE('123work123', '123');   
     Result: 'work'
REPLACE('222oracle', '2', '3'); 
     Result: '333oracle'
REPLACE('0000102300', '0');     
     Result: '123'
REPLACE('0000888', '0', ' ');   
     Result: '    888'

No comments:

Post a Comment

Search This Blog