First take the red colored part
Here, TempID(2) contains some string. And you add a Trim to that. This will remove the spaces in front and at the end of the string. But will not really remove the spaces in between.
" Country Name: Alaska "
Your trim here will make this string like this
“Country Name: Alaska”
Now get to the blue part.
Here you split that trimmed string again by the “:” character and you take the second element
So this is what happens when you split
You see, when split by that character, you actually have a space after that character. That’s why you are getting that space there.
So your code should be changed a bit like this