From 735a339deb3ca218d9f6e13877b4d62ced09e4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=82=B2=E6=96=B0?= Date: Wed, 5 Aug 2026 18:31:59 +0800 Subject: [PATCH] =?UTF-8?q?test(regularMatch):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=AD=A3=E5=88=99=E5=8C=B9=E9=85=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/testing/regularMatch/regexp_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 go/testing/regularMatch/regexp_test.go diff --git a/go/testing/regularMatch/regexp_test.go b/go/testing/regularMatch/regexp_test.go new file mode 100644 index 0000000..444bbea --- /dev/null +++ b/go/testing/regularMatch/regexp_test.go @@ -0,0 +1,21 @@ +package regularmatch + +import ( + "regexp" + "testing" +) + +func TestChineseRegExp(t *testing.T) { + reg, err := regexp.Compile("[\u4e00-\u9fa5]") + if err != nil { + t.Errorf("Failed to compile regex: %v", err) + } + matchStrSlice := reg.FindAllString("hello 世界", -1) + + if len(matchStrSlice) != 2 { + t.Errorf("Expected 2 matches, got %d", len(matchStrSlice)) + } + if matchStrSlice[0] != "世" || matchStrSlice[1] != "界" { + t.Errorf("Expected [世, 界], got %v", matchStrSlice) + } +}