[fpc-pascal] RE: Trim repeated whitespace from a string

Jeff Pohlmeyer yetanothergeek at gmail.com
Sat May 27 07:07:57 CEST 2006

> Anybody know of a function that can remove (normalize) a string
> by remove all beginning and ending whitespace

uses SysUtils;

> as well as replace all repeated spaces with a single space.

uses StrUtils;

> A bonus would be to remove tabs and newlines chars as well

I would convert them to spaces and let the functions above have them...
for i:=1 to length(S) do if ( S[i] in [#9..#13] ) then S[i]:=#32;

 - Jeff

More information about the fpc-pascal mailing list