github.com/andrewhsu/cli/v2@v2.0.1-0.20210910131313-d4b4061f5b89/pkg/text/sanitize.go (about) 1 package text 2 3 import ( 4 "regexp" 5 "strings" 6 ) 7 8 var ws = regexp.MustCompile(`\s+`) 9 10 func ReplaceExcessiveWhitespace(s string) string { 11 return ws.ReplaceAllString(strings.TrimSpace(s), " ") 12 }