Shiny Language Reference
Language Reference > String Functions
strreplace
string strreplace(string Target, string SubString, string Replacement);
Synonyms:
string replace(string Target, string SubString, string Replacement);
Replaces all occurrences of a substring in a string
STRREPLACE replaces all occurrences of a substring in a target string with the specified replacement string. The replacement string does not have to be the same length as the substring it replaces. The replacement string can also be empty, to remove all occurrences of a substring.
The dual syntax REPLACE can be used in place of STRREPLACE.
Parameters
Target
The string to search inside
SubString
The substring to locate in the target string
Replacement
The replacement string for the substring occurrences.
Return Value
The target string with all occurrences of the substring replaces by the replacement string.
Example Code
// RepString will contain "Th*s *s a test"
string RepString = strreplace("This is a test", "i", "*");
// Equivalent dual-syntax use
string RepString = replace("This is a test", "i", "*");