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)
| 619 | // // match[2] = "example" |
| 620 | // // match[3] = "com" |
| 621 | func (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. |