Forum > General
Remove newlines (line break) from memo1.text?
seba22:
Welcome,
I have memo component and long string.
How can i grab that string into one line, one long string without line braks maked by enter.
If user copy text from website, it contain that line breaks
If user paste text
--- Code: ---1
2
3
4
--- End code ---
I need to get
--- Code: ---1234
--- End code ---
I was trying write it on my own, but i cant
--- Code: ---procedure TForm1.Memo3Exit(Sender: TObject);
begin
memo3.text:=trim(memo3.text);
end;
--- End code ---
That was my idea.
It work ok, for enters at begining or end but not inside text
--- Code: ---enter
text1
enter
text2
enter
--- End code ---
after trim i got
--- Code: ---text1
enter
text2
--- End code ---
I should get : text1text2
Regards
typo:
Set WordWrap to False.
If you already did so, you could do:
--- Code: ---Memo1.Lines.Text := StringReplace(Memo1.Lines.Text, #13#10, '', [rfReplaceAll]);
--- End code ---
seba22:
Thank you, this code work for windows and linux ;)
--- Code: --- memo3.text:=trim(memo3.text);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #13#10, '', [rfReplaceAll]);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #13, '', [rfReplaceAll]);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #10, '', [rfReplaceAll]);
--- End code ---
typo:
--- Quote ---Maybe i need another line for linux systems ?
--- End quote ---
Yes.
DirkS:
--- Quote from: seba22 on December 27, 2010, 01:50:31 pm ---Thank you, this code work for windows and linux ;)
--- Code: --- memo3.text:=trim(memo3.text);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #13#10, '', [rfReplaceAll]);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #13, '', [rfReplaceAll]);
Memo3.Lines.Text := StringReplace(Memo3.Lines.Text, #10, '', [rfReplaceAll]);
--- End code ---
--- End quote ---
You don't need the first stringreplace; that situation is also covered by the other two.
Gr.
Dirk.
Navigation
[0] Message Index
[#] Next page