Overview
TheREPLACE()
function looks for and replaces a substring with a new one in a string. This function is often used to update the outdated or spelling mistakes in data that require an amendment.
Oxla also supports the
REGEXP_REPLACE()
function. It enables you to search and replace a substring that matches with a POSIX regular expressionSyntax
The syntax forREPLACE()
function is as follows:
The
REPLACE()
function performs a case-sensitive replacementParameters
The syntax requires three parameters, explained below:string
: string that you want to replaceold_substring
: substring that you want to replace (all parts will be replaced if it appears multiple times in the string)new_substring
: new substring that will replace the old one
Examples
Basic usage
In this example we will focus on a basic usage of theREPLACE()
function, so we can understand on real example how it works.
REPLACE()
function will find all occurrences of the ‘New’ substring in the ‘NewDatabase’ string and replace it with the ‘Oxla’ substring, producing the following output:
Replacing specified values in a table
This example shows how to replace the values of a specific column in a table. For the needs of this example, we will create a new table named extracurriculars with club and category columns and insert the values into the respective columns.Removing a substring from a stirng
In the following example, we will show how to remove a substring from a string using theREPLACE()
function. In this case we want to find all occurences of ‘Friends’ substring in ‘Hello Friends’ string and get rid of it:
Replacing multiple patterns
The following example uses theREPLACE()
function to replace multiple patterns of the given string:
REPLACE()
function is called multiple times to replace the corresponding string as specified:
[]
into()
{}
into()