This commit is contained in:
2023-03-31 13:33:06 +02:00
parent ca24e1d5bf
commit 2550691e2e
14 changed files with 331 additions and 191 deletions

View File

@@ -117,7 +117,7 @@ func (m RegexMatch) GroupByName(name string) RegexMatchGroup {
// GroupByName returns the value of a matched group (returns empty OptRegexMatchGroup if not found)
func (m RegexMatch) GroupByNameOrEmpty(name string) OptRegexMatchGroup {
for idx, subname := range m.subnames {
if subname == name {
if subname == name && (m.submatchesIndex[idx*2] != -1 || m.submatchesIndex[idx*2+1] != -1) {
return OptRegexMatchGroup{&RegexMatchGroup{haystack: m.haystack, start: m.submatchesIndex[idx*2], end: m.submatchesIndex[idx*2+1]}}
}
}