FStrReplace Function

Action

Replaces all occurrences of a search string by a replace string, within a source string. This action also modifies the source string.
注: Do not use this function in a load test, as it can impact the results.

Include file

Kernel.bdh

Syntax

FStrReplace(
   inout sSource        : string,
   in    sSearch        : string,
   in    sReplace       : string,
   in    bMatchCase     : boolean optional,
   in    bWholeWordOnly : boolean optional ) : string;
Parameter Description
sSource The source string within which you want to search.
sSearch The string within sSource that you are searching for.
sReplace The string that will replace sSearch. Note that sSource also changes, as soon as sSearch is changed.
bMatchCase 1 to perform a case-sensitive search. If you set this parameter to 0 or omit it, the search will not be case sensitive.
bWholeWordOnly This option allows the search to be restricted to whole words only. This is useful for searching for ' a ', or 'A' without finding all words including 'a'. Set this parameter to 1 to search for whole words only. If you set this parameter to 0 or omit it, the search will not be restricted to matching whole words only.

Example

dcltrans
  transaction TWeb
  var
    sSource : string;
    sSearch : string;
    sReplace : string;
    sOut : string;
  begin
    sSource := "An ideal pack for long trail trips, its strong heli-arc 
welded 6061-T6 aircraft-quality aluminum frame with V-truss design 
resists diagonal distortion.";
    sSearch := "ideal pack";
    sReplace := "optimal pack";
    sOut := FStrReplace(sSource, sSearch, sReplace);
    writeln(sOut);
  end TWeb;

Output

An optimal pack for long trail trips, its strong heli-arc 
welded 6061-T6 aircraft-quality aluminum frame with V-truss design 
resists diagonal distortion.