Solved

Need Help in Strings Replacing

Posted on 2003-12-02
3
204 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now