ExampleRegex_FindStringSubmatch demonstrates capture groups with strings.
()
| 103 | |
| 104 | // ExampleRegex_FindStringSubmatch demonstrates capture groups with strings. |
| 105 | func ExampleRegex_FindStringSubmatch() { |
| 106 | re := coregex.MustCompile(`(\d{4})-(\d{2})-(\d{2})`) |
| 107 | match := re.FindStringSubmatch("Date: 2024-12-25") |
| 108 | if match != nil { |
| 109 | fmt.Printf("Year: %s, Month: %s, Day: %s\n", match[1], match[2], match[3]) |
| 110 | } |
| 111 | // Output: Year: 2024, Month: 12, Day: 25 |
| 112 | } |
| 113 | |
| 114 | // ExampleRegex_NumSubexp demonstrates counting capture groups. |
| 115 | // NumSubexp returns the number of parenthesized subexpressions, |
nothing calls this directly
no test coverage detected