In simple terms, trim
removes whitespace from the beginning or end of a bit of text. For instance, it will turn 'myvalue '
into 'myvalue'
and ' tonsofexteriorwhitespace '
into 'tonsofexteriorwhitespace'
. Note that it won’t remove whitespace from the interior of the text though, so ' interior spaces remain '
becomes 'interior spaces remain'
.
It is often used to compare bits of whose actual content should be equal but may differ in leading or trailing spaces due to file loading/user input.
solved can you explain trim and what is doing? [closed]