MCPcopy Create free account
hub / github.com/coregx/coregex / CountString

Method CountString

regex.go:1361–1363  ·  view source on GitHub ↗

CountString returns the number of non-overlapping matches of the pattern in s. If n > 0, counts at most n matches. If n <= 0, counts all matches. Example: re := coregex.MustCompile(`\d+`) count := re.CountString("1 2 3 4 5", -1) // count == 5

(s string, n int)

Source from the content-addressed store, hash-verified

1359// count := re.CountString("1 2 3 4 5", -1)
1360// // count == 5
1361func (r *Regex) CountString(s string, n int) int {
1362 return r.engine.Count(stringToBytes(s), n)
1363}
1364
1365// FindAllSubmatch returns a slice of all successive matches of the pattern in b,
1366// where each match includes all capture groups.

Callers 2

TestStdlibCompat_CountFunction · 0.80
TestCountFunction · 0.80

Calls 2

stringToBytesFunction · 0.85
CountMethod · 0.45

Tested by 2

TestStdlibCompat_CountFunction · 0.64
TestCountFunction · 0.64