回答編集履歴
1
Update
test
CHANGED
@@ -4,19 +4,25 @@
|
|
4
4
|
|
5
5
|
import (
|
6
6
|
"fmt"
|
7
|
+
"index/suffixarray"
|
7
8
|
"regexp"
|
8
9
|
)
|
9
10
|
|
10
11
|
func main() {
|
11
|
-
r := regexp.MustCompile(`
|
12
|
+
r := regexp.MustCompile(`//[[:alpha:]]{1,3}fruit`)
|
12
13
|
strings := []string{"//abcfruit", "//abcdfruit", "//a1cfruit"}
|
13
14
|
for _, s := range strings {
|
15
|
+
index := suffixarray.New([]byte(s))
|
16
|
+
if idx := index.FindAllIndex(r, 1); idx != nil {
|
14
|
-
fmt.Println(
|
17
|
+
fmt.Println("Matched", s)
|
18
|
+
} else {
|
19
|
+
fmt.Println("Not matched", s)
|
20
|
+
}
|
15
21
|
}
|
16
22
|
}
|
17
23
|
|
18
24
|
#
|
19
|
-
t
|
25
|
+
Matched //abcfruit
|
20
|
-
|
26
|
+
Not matched //abcdfruit
|
21
|
-
|
27
|
+
Not matched //a1cfruit
|
22
28
|
```
|