mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-07 18:10:24 +08:00
优化代码/删除不需要的代码
This commit is contained in:
10
internal/utils/regexputils/expr.go
Normal file
10
internal/utils/regexputils/expr.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package regexputils
|
||||
|
||||
import "regexp"
|
||||
|
||||
var (
|
||||
YYYYMMDD = regexp.MustCompile(`^\d{8}$`)
|
||||
YYYYMM = regexp.MustCompile(`^\d{6}$`)
|
||||
)
|
||||
19
internal/utils/regexputils/expr_test.go
Normal file
19
internal/utils/regexputils/expr_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package regexputils_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExpr(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
a.IsTrue(regexputils.YYYYMMDD.MatchString("20221011"))
|
||||
a.IsFalse(regexputils.YYYYMMDD.MatchString("202210"))
|
||||
|
||||
a.IsTrue(regexputils.YYYYMM.MatchString("202210"))
|
||||
a.IsFalse(regexputils.YYYYMM.MatchString("20221011"))
|
||||
}
|
||||
Reference in New Issue
Block a user