mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Add query to find number of subexpressions.
This was convenient for me to have without being forced to parse the regexp myself. I'd understand if it's not really wanted, but I also think that some meta information about compiled regexps would be fine. R=r, rsc CC=golang-dev https://golang.org/cl/183044
This commit is contained in:
parent
b266f39b85
commit
e1033d07b4
2 changed files with 31 additions and 0 deletions
|
|
@ -677,6 +677,9 @@ func MustCompile(str string) *Regexp {
|
|||
return regexp
|
||||
}
|
||||
|
||||
// NumSubexp returns the number of parenthesized subexpressions in this Regexp.
|
||||
func (re *Regexp) NumSubexp() int { return re.nbra }
|
||||
|
||||
// The match arena allows us to reduce the garbage generated by tossing
|
||||
// match vectors away as we execute. Matches are ref counted and returned
|
||||
// to a free list when no longer active. Increases a simple benchmark by 22X.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue