?
Solved

Need Help in Strings Replacing

Posted on 2003-12-02
3
Medium Priority
?
210 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 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