Skip to content

StrReplace

String StrReplace(String input, String toReplace, String replaceWith, Bool ignoreCase = false)

System · system operation · implicitly imported

Replaces every occurrence of a substring in a String.

Parameters

  • String input — The String to replace in.
  • String toReplace — The substring to replace.
  • String replaceWith — The String to replace each occurrence with.
  • Bool ignoreCase = false — When true, toReplace is matched case-insensitively.

Returns

String — A new String in which every occurrence of toReplace is replaced by replaceWith.

Errors

A runtime type error if input, toReplace or replaceWith is not a String, or ignoreCase is not a Bool.

Examples

String s = StrReplace("Hello World", "World", "DMLA");

See Also