diff --git a/regex/compile.go b/regex/compile.go index a491e0f..fe324be 100644 --- a/regex/compile.go +++ b/regex/compile.go @@ -18,6 +18,12 @@ type Reg struct { numGroups int } +// numSubexp eturns the number of sub-expressions in the given [Reg]. This is equivalent +// to the number of capturing groups. +func (r Reg) NumSubexp() int { + return r.numGroups +} + const concatRune rune = 0xF0001 // Flags for shuntingYard - control its behavior