123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package stringutil
- import (
- "regexp"
- "testing"
- "time"
- "github.com/dlclark/regexp2"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/util/authutil"
- )
- func TestZhToPinyin(t *testing.T) {
- zh := "隐私级别1"
- l := []rune(zh)
- t.Logf("l %v", string(l[0:2]))
- sep := "_"
- got := ZhToPinyin(zh, sep)
- t.Logf("got: %v", SnakeToCamel(got, CamelSmall))
- }
- func TestCamelToSnake(t *testing.T) {
- got := CamelToSnake("AsdFert")
- t.Logf("got: %v", got)
- }
- func TestSnakeToCamel(t *testing.T) {
- p, _ := authutil.Encrypt("123123")
- t.Logf("密码:%s", p)
- t.Logf(time.UnixMilli(1678679758000).String())
- }
- func TestSnake(t *testing.T) {
- str := "wq1234"
- matched, _ := regexp.MatchString("^(?:.*\\d)(?:.*[a-zA-Z])[0-9a-zA-Z]*$", str)
- t.Logf("ret1: %v", matched)
- matched, _ = regexp.MatchString("^(.*\\d)(.*[a-zA-Z])[0-9a-zA-Z]*$", str)
- t.Logf("ret2: %v", matched)
- reg, _ := regexp2.Compile(`^((?=.*[0-9])(?=.*[a-zA-Z]).{6,50})$`, 0)
- matched, _ = reg.MatchString(str)
- t.Logf("ret3: %v", matched)
- }
|