README.md

December 4, 2022 · View on GitHub

Split Function in Delphi

Description

Hey this function just emulates the Visual Basic function that we know and love “split”!!! You use it the same way you would have in vb.

avar := split('string to break up',' ',2);

That will return avar as “to” that’s it, have fun and please vote!!

More Info

Submitted On
ByNick Siderakis
LevelIntermediate
User Rating4.5 (36 globes from 8 users)
CompatibilityDelphi 5, Delphi 4, Pre Delphi 4
CategoryString Manipulation
WorldDelphi
Archive File

Source Code

<pre><fontsize=2>function split(input:string;schar:char;s:integer):string;
var
   i,n:integer;
   schop: string;
begin
   n := 1;
   for i := 1 to length(input) do
   begin
     if (input[i] = schar) then
     begin
       inc(n);
       if n = s then
       split := schop
       else
       schop := '';
       end
     else
       schop := schop + input[i];
     end;
end;</pre>