photoprism/pkg/txt/strings.go
Michael Mayer 68c758a686 Backend: Improve location list for estimates #260
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-31 17:45:58 +02:00

24 lines
420 B
Go

package txt
import (
"regexp"
"strings"
)
var ContainsNumberRegexp = regexp.MustCompile("\\d+")
// ContainsNumber returns true if string contains a number.
func ContainsNumber(s string) bool {
return ContainsNumberRegexp.MatchString(s)
}
// Bool casts a string to bool.
func Bool(s string) bool {
s = strings.TrimSpace(s)
if s == "" || s == "0" || s == "false" || s == "no" {
return false
}
return true
}