StrTran Function | |
Search and replace characters within a string.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION StrTran(
uTarget,
uSearch,
uReplace,
uStart,
uCount
) AS STRING CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static string StrTran(
Usual uTarget = default,
Usual uSearch = default,
Usual uReplace = default,
Usual uStart = default,
Usual uCount = default
)
Request Example
View SourceParameters
- uTarget (Optional)
- Type: Usual
The string in which to search. - uSearch (Optional)
- 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 (Optional)
- Type: Usual
The substring with which to replace cSearch.
If this argument is not specified, cSearch is replaced with a NULL_STRING.
- uStart (Optional)
- Type: Usual
The first occurrence to replace.
If this argument is omitted or 0, the default is 1.
- uCount (Optional)
- 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:
1cString := "To compute or not to compute?"
2? StrTran(cString, "compute", "be")
3
See Also