1. Home
  2. Computing & Technology
  3. Delphi Programming

Delete line breaks from a string

By , About.com Guide

Here's how to remove line breaks (#10, #13) from a string (replacing em with space):

~~~~~~~~~~~~~~~~~~~~~~~~~
function DeleteLineBreaks(const S: string): string;
var
   Source, SourceEnd: PChar;
begin
   Source := Pointer(S) ;
   SourceEnd := Source + Length(S) ;
   while Source < SourceEnd do
   begin
     case Source^ of
       #10: Source^ := #32;
       #13: Source^ := #32;
     end;
     Inc(Source) ;
   end;
   Result := S;
End;

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Two (or more) line Hint box
« Flip Bitmap (Horizontal or Vertical)

Explore Delphi Programming
About.com Special Features

Reader's Choice Award Winners

What are the best instant messengers, apps, editors and more? You told us, for our 2010 technology awards program. More >

iPad Central

Is Apple's new tablet computer impractical, a must-have -- or both? We'll help you figure it out. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. Delete line breaks from a string

©2010 About.com, a part of The New York Times Company.

All rights reserved.