2.5.4.103 Substitute

The Substitute function performs text substitution by finding a substring in a text string and replacing it with another text string.

ABNF:

 Substitute = val val val [val [val]] sp ("3" / "4" /"5") ";SUBSTITUTE():129"

Required Arguments:

Name: SourceText

Type: vString

An argument that specifies the string to perform substitution on.

Name: FindText

Type: vString

An argument that specifies the substring in SourceText to be substituted.

Name: SubstituteText

Type: vString

An argument that specifies the string to use for substitution.

Optional Arguments:

Name: WhichInstance

Type: vSignedLong

An argument that specifies which instance, among multiple instances of FindText in SourceText, is to be substituted. The default value is 0.

Name: IgnoreCase

Type: vBoolean

An argument that specifies whether the search for FindText in SourceText is case insensitive. A value of TRUE specifies that case is ignored. The default value is FALSE.

Return Value:

Type: PtgStr1, PtgErr

This function returns a PtgStr1 containing SourceText modified with the substituted text. If WhichInstance is zero, the function returns a PtgErr with an error code of #VALUE!. If WhichInstance is less than zero or greater than the number of FindText instances in SourceText, or if FindText is not found in SourceText, the function returns a PtgStr1 containing SourceText without any substitution. The search is performed according to .NET globalization rules based on the LCID in the DocumentLanguage field of the Properties GlobalElement in the App XML Part of the document. For more information about .NET globalization rules, see [MSDN-ENCLOC].