add quote support for table named with '.'; improve case conversion for strings named with '.' for gstr

This commit is contained in:
John
2019-09-16 17:15:39 +08:00
parent 0d87b601cc
commit 1d7ded562c
4 changed files with 7 additions and 6 deletions

View File

@ -2,10 +2,10 @@ package main
import (
"fmt"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/text/gstr"
)
func main() {
file := "xxx/github.com/hg-hh/ww/gf/.example/"
fmt.Println(gregex.IsMatchString(`/github.com/[^/]+/gf/\.example/`, file))
fmt.Println(gstr.CamelCase("userLoginLog.bak"))
}

View File

@ -31,7 +31,7 @@ const (
)
var (
wordReg = regexp.MustCompile(`^[a-zA-Z0-9\-_]+$`)
wordReg = regexp.MustCompile(`^[a-zA-Z0-9\-_\.]+$`)
lastOperatorReg = regexp.MustCompile(`[<>=]+\s*$`)
)

View File

@ -90,7 +90,7 @@ func DelimitedScreamingCase(s string, del uint8, screaming bool) string {
} else if v >= 'a' && v <= 'z' {
n += string(v) + string(del)
}
} else if v == ' ' || v == '_' || v == '-' {
} else if v == ' ' || v == '_' || v == '-' || v == '.' {
// replace spaces/underscores with delimiters
n += string(del)
} else {
@ -132,7 +132,7 @@ func toCamelInitCase(s string, initCase bool) string {
n += string(v)
}
}
if v == '_' || v == ' ' || v == '-' {
if v == '_' || v == ' ' || v == '-' || v == '.' {
capNext = true
} else {
capNext = false

View File

@ -20,6 +20,7 @@ func Test_CamelCase(t *testing.T) {
{"test", "Test"},
{"TestCase", "TestCase"},
{" test case ", "TestCase"},
{"userLogin_log.bak", "UserLoginLogBak"},
{"", ""},
{"many_many_words", "ManyManyWords"},
{"AnyKind of_string", "AnyKindOfString"},