Remove   in string

Hello

what is the best option to remove "   " in string? I am getting this in text and I need to remove it.

tnx

Ok, it depends on where exactly you want to remove this space character from.

  1. https://golang.org/pkg/strings/#TrimRight - to remove from the right
  2. https://golang.org/pkg/strings/#TrimLeft - to remove from the left
  3. https://golang.org/pkg/strings/#ReplaceAll - to remove from anywhere inside a string
2 Likes

You can also use string.Trim which remove leading and trailing spaces (&nbsp)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.