How can I remove all white space from the beginning and end of a string?
Like so:
"Test User Image"
returns "Test User Image"
"Test User Image "
returns "Test User Image"
" Test User Image "
returns "Test User Image"
" Test User Image "
returns "Test User Image"
Question: How to remove all the white spaces from a string at the beginning or end?
Can someone please explain to me how to remove all the white spaces, I've tried with the below answers but no results yet.
How should I remove all the leading spaces from a string? - swift
How to remove all the spaces and \n\r in a String?
Any help would be greatly appreciated.
Thanks in advance.