String.ReplaceText

Top  Previous  Next

 

Syntax

function String.ReplaceText(SourceTxt: string; SearchTxt: string; ReplaceTxt: string): string

 

Description

Replaces the first occurrence of SearchTxt by ReplaceTxt in the given SourceTxt and Returns this as the new value. The search is case insensitive.

 

To replace all occurrences with a case insensitive search, you can use String.ReplaceAllText.

 

See also

String.Replace
String.ReplaceAll
String.ReplaceAllText

 

Example

execute udsblock

as

begin

  /* replace first 'in', search case insensitive 

     returns 'Output Input'

  */    

  valueout = String.Replace('Input Input', 'in', 'Out', __rfIgnoreCase);

  

  /* replace all 'In', search case sensitive

     returns 'input Output Output'

  */

  valueout = String.ReplaceAll('input Input Input', 'In', 'Out');

 

  /* replace first 'in', search case insensitive 

     returns 'Output Input'

  */

  valueout = String.ReplaceText('Input Input', 'in', 'Out');

  

  /* replace all 'in', search case insensitive 

     returns 'Output Output'

  */

  valueout = String.ReplaceAllText('Input Input', 'in', 'Out');

end