How to remove all white space from the beginning or end of a string?

How can I remove all white space from the beginning and end of a string?

Like so:

"hello" returns "hello"
"hello " returns "hello"
" hello " returns "hello"
" hello world " returns "hello world"

7 Answers
7

Leave a Comment