How can I remove a trailing newline?

How can I remove the last character of a string if it is a newline?

"abc\n"  -->  "abc"

← Назад к списку