diff --git a/lib/chibi/regexp.scm b/lib/chibi/regexp.scm index 464da7ba..1440a86a 100644 --- a/lib/chibi/regexp.scm +++ b/lib/chibi/regexp.scm @@ -99,8 +99,8 @@ (%make-regexp-match (make-vector len #f) rx str)) (define (make-regexp-match-for-rx rx str) (make-regexp-match (rx-num-save-indexes rx) rx str)) -(define (regexp-match-num-matches md) - (vector-length (regexp-match-matches md))) +(define (regexp-match-count md) + (- (quotient (vector-length (regexp-match-matches md)) 2) 1)) (define (regexp-match-name-offset md name) (let lp ((ls (regexp-match-names md)) (first #f)) diff --git a/lib/chibi/regexp.sld b/lib/chibi/regexp.sld index 05af22b0..4d132b62 100644 --- a/lib/chibi/regexp.sld +++ b/lib/chibi/regexp.sld @@ -4,7 +4,7 @@ regexp-matches regexp-matches? regexp-search regexp-replace regexp-replace-all regexp-fold regexp-extract regexp-split - regexp-match? regexp-match-num-matches + regexp-match? regexp-match-count regexp-match-submatch regexp-match-submatch/list regexp-match->list regexp-match->sexp) (import (srfi 33) (srfi 69))