Click or drag to resize

StrTran Function

Search and replace characters within a string.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION StrTran(
	 uTarget AS USUAL,
	 uSearch AS USUAL,
	 uReplace AS USUAL,
	 uStart AS USUAL,
	 uCount AS USUAL
) AS STRING
View Source

Parameters

uTarget
Type: Usual
The string in which to search.
uSearch
Type: Usual
The substring for which to search.  All occurrences of <uSearch> are replaced unless <uStart> or <uCount> is specified.  Note that StrTran() replaces substrings and, therefore, does not account for whole words.
uReplace
Type: Usual
The substring with which to replace <cSearch>.  If this argument is not specified, <cSearch> is replaced with a NULL_STRING.
uStart
Type: Usual
The first occurrence to replace.  If this argument is omitted or 0, the default is 1.  
uCount
Type: Usual
The number of occurrences to replace.  If this argument is not specified, the default is all.

Return Value

Type: String
A new string with the specified occurrences of <uSearch> replaced by <uReplace>.
Remarks
Examples
This example uses StrTran() to convert a postmodern analog to a famous quotation:
X#
cString := "To compute or not to compute?"
? StrTran(cString, "compute", "be")
// To be or not to be?
See Also