U can use TRIM function to remove the extra space that appear in the begenning or end of the string.


=Trim(A1)