www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
and
append
assign
avg
boolean
ceiling
concat
contains
count
create-attribute
create-comment
create-element
create-pi
current
distinct
doc
document
document-literal
empty
ends-with
every
except
false
filter
floor
fn:collection
for
format-number
function-available
generate-id
id
if
intersect
is_after()
is_before()
key
lang
last
let
list()
local-name
max
min
name
namespace-uri
normalize-space
not
number
or
position
processxquery
processxslt
processxsql
progn()
replace()
round
serialize
shallow
some
starts-with
string
string-length
substring
substring-after
substring-before
sum
system-property
text_contains()
translate
true
tuple()
union
unordered
unparsed-entity-uri
urlify
xmlview

Functions Index

replace()

Searches for an substring and replace its occurences with other substring.
string replace() ( txt string, search_strg string, replace_strg string);
Description

The function searches for all occurences of a search_strg in txt and replaces every occurence 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
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

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

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