ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 语法 ``` type Index func New(data []byte) *Index func (x *Index) Bytes() []byte func (x *Index) Read(r io.Reader) error func (x *Index) Write(w io.Writer) error func (x *Index) Lookup(s []byte, n int) (result []int) func (x *Index) FindAllIndex(r *regexp.Regexp, n int) (result [][]int) ``` ## 示例 ``` index := suffixarray.New([]byte("abc abc abc")) offsets := index.Lookup([]byte("bc"), -1) fmt.Printf("%+v\n", offsets) // [9 5 1] compile := regexp.MustCompile("bc") allIndex := index.FindAllIndex(compile, -1) fmt.Printf("%+v\n", allIndex) // [[1 3] [5 7] [9 11]] ```