DelphiBasics
TReplaceFlags
Type
Defines options for the StringReplace routine SysUtils unit
type TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
Description
The TReplaceFlags enumeration type gives the options for the StringReplace routine :
 
rfReplaceAll  Replace all find occurences
rfIgnoreCase  Find ignores case
Related commands
StringReplaceReplace one or more substrings found within a string
 Download this web site as a Windows program.




 
Example code : Change all occurences regardless of case
var
  before, after : string;
  options       : TReplaceFlags;

begin
  // Try to replace all occurrences of a or A to THE
  before := 'This is a way to live A big life';

  // Set the options to change all occurences regardless of case
  options := [rfReplaceAll, rfIgnoreCase];

  // Now change 'a' or 'A' to 'THE' throughout
  after  := StringReplace(before, ' a ', ' THE ', options);

  // Show the before and after
  ShowMessage('Before = '+before);
  ShowMessage('After  = '+after);
end;
Show full unit code
  This is a way to live A big life
  This is THE way to live THE big life
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page