DelphiBasics
StuffString
Function
Replaces a part of one string with another StrUtils unit
 function StuffString ( const Source : string; Start, Length : Cardinal; const SubString : string ) : string;
Description
The StuffString function inserts a SubString into another string, replacing Length characters at position Start.
 
If the length is -1, then teh string is simply inserted, and does not replace any characters.
Notes
Strings are indexed from 1 (arrays from 0).
Related commands
AnsiReplaceStr Replaces a part of one string with another
Copy Create a copy of part of a string or an array
Insert Insert a string into another string
Move Copy bytes of data from a source to a destination
StringReplace Replace one or more substrings found within a string
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.


 
Example code : A simple example
var
  source, target : AnsiString;
begin
  source := '123456789';
  target := StuffString(source, 2, 4, '-inserted-');

  ShowMessage('Source = '+source);
  ShowMessage('Target = '+target);
end;
Show full unit code
   Source = 123456789
   Target = 1-inserted-6789
 
Delphi Programming Neil Moffatt 2002 - 2016. All rights reserved.  |  Home Page