This commit is contained in:
Daniel 2024-04-13 11:45:33 +08:00
parent 86f92208bf
commit 47aa891f34
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 31 additions and 28 deletions

View file

@ -24,6 +24,7 @@ import (
"time"
"unicode"
"github.com/88250/gulu"
"github.com/88250/lute/html"
)
@ -117,9 +118,13 @@ func RemoveRedundantSpace(str string) string {
return buf.String()
}
func IsNumeric(s string) bool {
_, err := strconv.ParseFloat(s, 64)
return err == nil
func Convert2Float(s string) (float64, bool) {
s = gulu.Str.RemoveInvisible(s)
ret, err := strconv.ParseFloat(strings.TrimSpace(s), 64)
if nil != err {
return 0, false
}
return ret, true
}
func ContainsSubStr(s string, subStrs []string) bool {