rss-dl/helpers/string_methods.go

16 lines
261 B
Go
Raw Normal View History

2019-04-17 20:26:44 +01:00
package helpers
import (
"log"
"regexp"
)
// ToCleanString - replaces spaces with underscores
func ToCleanString(str string) string {
reg, err := regexp.Compile("[^A-Za-z0-9]+")
if err != nil {
log.Fatal(err)
}
return reg.ReplaceAllString(str, "_")
}