-7

I am using the trim function to a string but as I see it is not working well. I have text, text_trim: string and I do :

text := memo1.text;
text_trim := text.Trim;

But it is not working. It just copies the string.

If I write for example in the memo: "Hello how are you?" text content is this(Hello how are you?) and text_trim has also the same content. I want to trim white spaces in a text.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
igli
  • 40
  • 1
  • 3

1 Answers1

4

Trim removes leading and trailing space. It does not remove internal space. For example you could use StringReplace for that.

NewStr := OldStr.Replace(' ', '', [rfReplaceAll]);

This just replaces the space character. If you want to replace all whitespace then you need something a little more advanced. Probably a regex would be the simplest way to achieve that.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490