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

Function ExampleRegex_FindStringSubmatch

example_test.go:105–112  ·  view source on GitHub ↗

ExampleRegex_FindStringSubmatch demonstrates capture groups with strings.

()

Source from the content-addressed store, hash-verified

103
104// ExampleRegex_FindStringSubmatch demonstrates capture groups with strings.
105func 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,

Callers

nothing calls this directly

Calls 2

MustCompileFunction · 0.92
FindStringSubmatchMethod · 0.80

Tested by

no test coverage detected