多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[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]] ```