-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathregexp_test.go
60 lines (43 loc) · 1.04 KB
/
regexp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"regexp"
"strings"
"testing"
)
//TestMatcher
func TestMatcher(t *testing.T) {
reg := regexp.MustCompile("tes.")
t.Log(reg.MatchString("test"))
t.Log(reg.MatchString("testt"))
t.Log(reg.MatchString("testtee"))
reg = regexp.MustCompile("t.e.*s.*$")
t.Log(reg.FindAllIndex([]byte("testteaabtestteaa"),2))
t.Log(reg.MatchString("testaa"))
t.Log(reg.MatchString("testteaab"))
//rxp := &syntax.Regexp{}
i := 0
to:
for ;i< 10 ; i ++ {
fmt.Println(i)
if i%2 == 1{
continue to
}
}
}
func TestMatcher01(t *testing.T) {
reg := regexp.MustCompile("hotels")
t.Log(string(reg.Find([]byte("hotels"))))
t.Log(reg.FindStringSubmatch("hotels"))
t.Log(strings.Trim(`{name}`,"{}"))
reg = regexp.MustCompile("/(.*).*")
t.Log(reg.FindString("/42.html"))
reg = regexp.MustCompile("^([\\p{L}\\.]+)&")
t.Log(reg.FindString("/A-b-C"))
reg = regexp.MustCompile("/A-(.*)-C")
indexs := reg.FindSubmatch([]byte("/A-b-C"))
for index := range indexs {
t.Log(index)
t.Log(fmt.Sprint(string(indexs[index])))
}
}