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

Method FindSubmatch

regex.go:621–627  ·  view source on GitHub ↗

FindSubmatch returns a slice holding the text of the leftmost match and the matches of all capture groups. A return value of nil indicates no match. Result[0] is the entire match, result[i] is the ith capture group. Unmatched groups will be nil. Example: re := coregex.MustCompile(`(\w+)@(\w+)\.(

(b []byte)

Source from the content-addressed store, hash-verified

619// // match[2] = "example"
620// // match[3] = "com"
621func (r *Regex) FindSubmatch(b []byte) [][]byte {
622 match := r.engine.FindSubmatch(b)
623 if match == nil {
624 return nil
625 }
626 return match.AllGroups()
627}
628
629// FindStringSubmatch returns a slice of strings holding the text of the leftmost
630// match and the matches of all capture groups.

Callers 6

FuzzFindSubmatchStdlibFunction · 0.45
BenchmarkFindSubmatchFunction · 0.45
FindStringSubmatchMethod · 0.45
FindSubmatchIndexMethod · 0.45

Calls 1

AllGroupsMethod · 0.80

Tested by 4

FuzzFindSubmatchStdlibFunction · 0.36
BenchmarkFindSubmatchFunction · 0.36