我使用 regexp.FindAll() 来获取所有匹配项。我不太明白这个参数n,而且office参考中,也没有解释。我该如何设置参数。
// FindAll is the 'All' version of Find; it returns a slice of all successive
// matches of the expression, as defined by the 'All' description in the
// package comment.
// A return value of nil indicates no match.
func (re *Regexp) FindAll(b []byte, n int) [][]byte {}
Run Code Online (Sandbox Code Playgroud)
来自https://golang.org/pkg/regexp/:
查找(全部)?(字符串)?(子匹配)?(索引)?
如果存在“All”,则例程将匹配整个表达式的连续非重叠匹配。与前面的匹配项相邻的空匹配项将被忽略。返回值是一个包含相应非“All”例程的连续返回值的切片。这些例程需要一个额外的整数参数 n;如果 n >= 0,则该函数最多返回 n 个匹配/子匹配。