mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-23 04:58:47 +02:00
30 lines
514 B
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
|
|
}
|