Answer the question
In order to leave comments, you need to log in
GoLang working with strings?
I'm trying to cut out spaces and letters from a string, I managed to cut out the letters using Trim, but I can't figure out how to get the spaces.
package main
import (
"fmt"
"strings"
)
func main() {
str := "5 000 000 шт"
str2 := strings.Trim(str, " шт")
fmt.Println(str2)
}
Answer the question
In order to leave comments, you need to log in
You can use strings.Replace
str := "5 000 000 шт"
str2 := strings.Replace(str, " ", "", -1)
// str2 будет содержать: "5000000шт"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question