WOLFRAM SYSTEM MODELER

replace

Replace non-overlapping occurrences of a string from left to right

Wolfram Language

In[1]:=
SystemModel["Modelica.Utilities.Strings.replace"]
Out[1]:=

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

Strings.replace(string, searchString, replaceString);
Strings.replace(string, searchString, replaceString,
                startIndex=1, replaceAll=true, caseSensitive=true);

Description

Search in "string" for "searchString" and replace the found substring by "replaceString".

  • The search starts at the first character of "string", or at character position "startIndex", if this optional argument is provided.
  • If the optional argument "replaceAll" is true (default), all occurrences of "searchString" are replaced. If the argument is false, only the first occurrence is replaced.
  • The search for "searchString" distinguishes upper and lower case letters. If the optional argument "caseSensitive" is false, the search ignores whether letters are upper or lower case.
  • It is intended for ASCII. The case-insensitive search is not guaranteed to work for UTF-8.

The function returns the "string" with the performed replacements.

Syntax

result = replace(string, searchString, replaceString, startIndex, replaceAll, caseSensitive)

Inputs (6)

string

Type: String

Description: String to be modified

searchString

Type: String

Description: Replace non-overlapping occurrences of 'searchString' in 'string' with 'replaceString'

replaceString

Type: String

Description: String that replaces 'searchString' in 'string'

startIndex

Default Value: 1

Type: Integer

Description: Start search at index startIndex

replaceAll

Default Value: true

Type: Boolean

Description: = false, if only the first occurrence is replaced, otherwise all occurrences

caseSensitive

Default Value: true

Type: Boolean

Description: = false, if lower and upper case are ignored when searching for searchString

Outputs (1)

result

Type: String

Description: Resultant string of replacement operation