summaryrefslogtreecommitdiff
path: root/src/regexp
diff options
context:
space:
mode:
Diffstat (limited to 'src/regexp')
-rw-r--r--src/regexp/syntax/parse.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go
index 3dc8ccf50..d579a4069 100644
--- a/src/regexp/syntax/parse.go
+++ b/src/regexp/syntax/parse.go
@@ -272,13 +272,18 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (
func repeatIsValid(re *Regexp, n int) bool {
if re.Op == OpRepeat {
m := re.Max
+ if m == 0 {
+ return true
+ }
if m < 0 {
m = re.Min
}
if m > n {
return false
}
- n /= m
+ if m > 0 {
+ n /= m
+ }
}
for _, sub := range re.Sub {
if !repeatIsValid(sub, n) {