SubstituteChars()

Summary

Returns the input string with all occurrences of the characters listed in the find string replaced with the characters in the replacement string.

Changes

Added to Version 2018.

Syntax

new_string = SubstituteChars(string input_str, string find_str, string repl_str)

Argument Contents
input_str The input string
find_str The characters to be located and replaced
repl_str The new characters that are to replace the find_str characters

Returns

A string where the characters in find_str are replaced with the characters in repl_str.

Notes

  • If repl_str has the same number of characters as find_str, the first character of find_str is replaced with the first character of repl_str, etc.

  • If repl_str has one character, all characters of find_str are replaced with that character.

  • If repl_str is null, all characters of find_str are removed.

  • SubstituteChars() is useful for standardizing accents.

Examples

s = SubstituteChars("cavolate","aeou","i") // Returns "civiliti"
s = SubstituteChars("cavolate","aeou","") // Returns "cvlt"
s = Upper(SubstituteChars("QUéBEC YUCATáN MéXICO","éá","ea")) // Returns "QUEBEC YUCATAN MEXICO"

See Also

Function Summary
Position() Returns the position of a substring within a string
PositionFrom() Search for the first occurrence of a substring within a string, starting the search at a designated position
PositionTo() Search for the last occurrence of a substring within a string, ending the search at a designated position
Substitute() Replaces a matching substring with a new string
Substring() Extracts a portion of a string