;; ;; foo =~ /(bar)/ ;; $1 # => "bar" ;; ;; (irregex-search "(bar)" foo) ;; ($ 1) ; => "bar" ;; (module irregex-dollar ($ irregex-match irregex-search) (import scheme chicken) (require-library irregex) (import (rename irregex (irregex-match orig-irregex-match) (irregex-search orig-irregex-search))) (reexport (except irregex irregex-match irregex-search)) (define last-match (make-parameter #f)) (define ($ n) (and-let* ((m (last-match))) (and (<= n (irregex-match-num-submatches m)) (irregex-match-substring m n)))) (define-syntax dollarize (syntax-rules () ((_ from to) (define (to . args) (let ((m (apply from args))) (last-match m) m))))) (dollarize orig-irregex-match irregex-match) (dollarize orig-irregex-search irregex-search))