Solved

Need Help in Strings Replacing

Posted on 2003-12-02
3
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 20 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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