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

Method FindStringSubmatch

regex.go:638–644  ·  view source on GitHub ↗

FindStringSubmatch returns a slice of strings holding the text of the leftmost match and the matches of all capture groups. Example: re := coregex.MustCompile(`(\w+)@(\w+)\.(\w+)`) match := re.FindStringSubmatch("user@example.com") // match[0] = "user@example.com" // match[1] = "user"

(s string)

Source from the content-addressed store, hash-verified

636// // match[0] = "user@example.com"
637// // match[1] = "user"
638func (r *Regex) FindStringSubmatch(s string) []string {
639 match := r.engine.FindSubmatch(stringToBytes(s))
640 if match == nil {
641 return nil
642 }
643 return match.AllGroupStrings()
644}
645
646// FindSubmatchIndex returns a slice holding the index pairs for the leftmost
647// match and the matches of all capture groups.

Calls 3

stringToBytesFunction · 0.85
AllGroupStringsMethod · 0.80
FindSubmatchMethod · 0.45