String Intrinsic Functions - ReplaceSubstring Method

Replace a portion of a string with a new value

Member of String Intrinsic Functions (PRIM_LIBI.ICommonStringIntrinsics)

Parameters

Name Type Data Type Description
Result *Result (Optional) String Resulting string
StartPosition *Input Integer Position at which to start the replacing characters
Length *Input Integer Number of characters to replace
With *Input String String to insert
Pad *Input (Optional) String Pad character used to replace blanks in the result

Details

ReplaceSubstring replaces the characters from the StartPosition for the specified length with the contents of the With parameter.
 
If the length exceeds the available characters, the remainder is ignored.

Example

In this example, if #String contained "ABCDE", the result would be "XYZDE".
#Com_owner.Caption := #String.ReplaceSubstring( 1 3 "XYZ" )
In this example, if #String contained "ABCDE", the result would be "AXYZCDE".
#Com_owner.Caption := #String.ReplaceSubstring( 2 1 "XYZ" )
In this example, if #String contained "ABCDE", the result would be "ABCDE****XYZ".
#Com_owner.Caption := #String.ReplaceSubstring( 10 1 "XYZ" "*" )

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020