[fpc-pascal] splitting string into array

Marc Santhoff M.Santhoff at t-online.de
Wed Jul 11 17:46:46 CEST 2007

Am Mittwoch, den 11.07.2007, 12:09 +0200 schrieb Michael Van Canneyt:
> On Tue, 10 Jul 2007, Marc Santhoff wrote:


> > Wouldn't this function be a candidate for crawling into the 'strutils'
> > unit?
> Probably, but I would change the interface:
> function Split(const str: string; const separator: string; var Res : array of string) : Integer;
> So the function returns the number of elements in the array. 
> The function could also use some speedup. Deleting the parts 
> which are no longer needed causes a lot of memory fragmentation.

I'd second your opinion about the interface, but regarding speedup and
memory fragmentation makes me think.

For speed I'd need some hints, what technique would be faster/fastest?

And for memory fragmentation: avoiding Copy could be done by using
pointers running over the input string, or is there an even better

Marc (not having found any information about 'this is faster than
that' ;)

More information about the fpc-pascal mailing list