This function is used to replace a string of text.
The oxy_replace() function has two signatures:
- Syntax 1:
-
oxy_replace
(
text
,
target
,
replacement
)
This function replaces each substring of the text that matches the literal target
string with the specified literal replacement string.
- text
- The text in which the replace will occur.
- target
- The target string to be replaced.
- replacement
- The string replacement.
Example: Suppose that you have image
references but you want to see other thumbnail images that reside in the same folder
in the visual
Author editing
mode:
image[href]{
content:oxy_url(oxy_base-uri(), oxy_replace(attr(href),
'.jpeg', 'Thumbnail.jpeg'));
}
- Syntax 2:
-
oxy_replace
(
text
,
target
,
replacement
,
isRegExp
)
This function replaces each substring of the text that matches the target string with
the specified replacement string.
-
text
- The text in which the replace will occur.
-
target
- The target string to be replaced.
-
replacement
- The string replacement.
-
isRegExp
- If true the target and replacement arguments are considered regular
expressions, if false they are considered literal strings.
Example: Suppose that you want to use a regular
expression to replace all space sequences with an
underscore:
image[title]{
content:oxy_replace(attr(title), "\\s+", "_", true)
}