[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need Help in Strings Replacing

Posted on 2003-12-02
3
Medium Priority
?
212 Views
Last Modified: 2010-04-05
hi I would like some help with this.

I need a memo1.text

I need all the spacings in the example below looking like
before
Fla Flo, D E L T H I     yyyy
after
FlaFlo,DELTHIyyyy

I also need memo1.text lines sorting so that there are no more lines just 1 line
before
Fla Flo, D E L T H I     yyyy
Fla Flo, D E L T H I     yyyy
Fla Flo, D E L T H I     yyyy
after
Fla Flo, D E L T H I     yyyyFla Flo, D E L T H I     yyyyFla Flo, D E L T H I


could anyone help me?
0
Comment
Question by:Eolaz
3 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9858286
var s1, s2 : string;
i, j : integer;
found : boolean;

s1 := 'Fla Flo, D E L T H I     yyyy';
s2 := '';
for i := 1 to Length(s1) do if s1[i] > #32 then s2 := s2 + s1[i];

for i := memo1.Lines.Count - 1 downto 0 do begin
  s1 := memo1.Lines[i];
  found := false;
  for j := 0 to i - 1 do begin
    if memo1.Lines[j] = s1 then found := true;
  end;
  if found then memo1.Lines.Delete(i);
end;

Geoff M.
0
 
LVL 2

Accepted Solution

by:
cqhall earned 80 total points
ID: 9858518
Another approach...

Remove spaces:
  memo1.lines.text:=stringreplace(memo1.lines.text,' ','',[rfReplaceAll]);

Remove CR/LF:
 memo1.lines.text:=stringreplace(memo1.lines.text,#13#10,'',[rfReplaceAll]);
0
 

Author Comment

by:Eolaz
ID: 9858648
Doh! I'd forgot about that rfreplaceAll, silly me lol, I left that part blank, no wonder it didn't work. lol

thxs for reminding me cqhall
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question