match-group-regexp [ skip-first-match ] [ first-match ] bi* ;
:: update-match-group ( str match regexp n -- str' )
- n H{ } [ 1 + CHAR: $ swap "" 2sequence ] cache :> x
- x str subseq? [
- x match "" like regexp n nth-match str replace
- ] [ str ] if ;
+ n H{ } [ CHAR: 1 + CHAR: $ swap "" 2sequence ] cache :> x
+ x str subseq-range :> ( from to )
+ from [
+ to str snip-slice match regexp n nth-match glue
+ ] [ str ] if* ;
: update-match-groups ( str match regexp -- str' )
+ [ >string ] dip
dup #match-groups [ update-match-group ] 2with each-integer ;
GENERIC: fixup-end ( match regexp end -- end' )