Name

replace — Searches for an substring and replace its occurrences with other substring.

Synopsis

string replace ( txt string ,
search_strg string ,
replace_strg string );

Description

The function searches for all occurrences of a search_strg in txt and replaces every occurrence with replace_strg . An error is signalled if search_strg is empty.

Parameters

txt

Text to process.

search_strg

Substring to search for txt .

replace_strg

Substring to replace search_strg in txt .

Return Types

String.

Errors

Table24.150.Errors signalled by

SQLState Error Code Error Text Description
XP001 XPF08 Empty string passed as argument 2 to XPATH function replace() It is impossible to search for an empty substring.
XP001 XPF14 The result of XPATH function replace() is too long If the function replaces short substring with longer one, the result is longer than the original string and may exceed 10Mb limit.

Examples

Example24.615.

Replace all occurrences of 'http://www.example.com/' with '/webrobot/'

replace(
  '<A HREF="http://www.example.com/index.html">Home</A>',
  'http://www.example.com/', '/webrobot/' )

See Also

translate