From 206fea34cd6a0909e508e8fff81f5693f54ac503 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sat, 1 Feb 2025 11:04:49 -0500 Subject: [PATCH] Added function to return the number of subexpressions in the group --- regex/compile.go | 6 ++++++ 1 file changed, 6 insertions(+) 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