user1531714
user1531714

Reputation: 111

How can I remove control characters from a string?

I have a string which contains some trailing control characters:

'ase_Record'#$A#9#9#9'

I tried to use StringReplace to remove the control characters, but could not make it work. How can I remove these control characters?

Upvotes: 1

Views: 2158

Answers (1)

David Heffernan
David Heffernan

Reputation: 612894

You can use Trim:

MyString := Trim(MyString);

From the documentation:

Trims leading and trailing spaces and control characters from a string.

Perhaps you only want to trim from the end of the string. In which case use TrimRight. And for completeness there is also TrimLeft for those times when you only want to trim from the start of the string.

Upvotes: 6

Related Questions