Files
htwkalender/backend/service/functions/string.go

30 lines
514 B
Go

package functions
import "unicode"
// check if course is empty or contains only whitespaces
func OnlyWhitespace(word string) bool {
for _, letter := range word {
if !unicode.IsSpace(letter) || !(letter == int32(160)) {
return false
}
}
return true
}
func Contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
func ReplaceEmptyString(word string, replacement string) string {
if OnlyWhitespace(word) {
return replacement
}
return word
}