Field-Map Scripting

4.1.2.8 StringReplace

StringReplace function


Prototype:

function StringReplace (const Data, OldPattern, NewPattern : string; const ReplaceAll,CaseInsensitive :boolean) :string;

Description:

The StringReplace function replaces occurences of a substring OldPattern in Data string with NewPattern according parameters ReplaceAll and CaseInsensitive.

Syntax:

variable := StringReplace (Data, OldPattern, NewPattern, ReplaceAll, CaseInsensitive);


Part

Description


variable

Variable declared as a string


Data

String attributes containing text data


OldPattern

A string to be replaced


NewPattern

A new string replacing parameter OldPattern


ReplaceAll

False - replace first occurence in Data string, True - replace all occurences with NewPattern


CaseInsensitive

False - not ignore case sensitive, True - ignore case sensitive

Return value:

changed string



Example:


var

 before, after : string;


begin

 before:= ' A tree is in a research area ';

 after:= StringReplace(before, ' a ', ' the ', true, false);

 ShowMessage('before text: ' + before + #13#10 + 'after text: ' + after);  // #13#10 is a new line

end.


Output in Field-Map Data Collector:


See also:

Format; LZero; Delete; Trim; TrimLeft; TrimRight; SameText; StringReplace; DeFormat1-10; GetFieldCountFromString;GetFieldFromString; IndexOfField; SortNumericSequence