regexp-replace*: recognize \$ as empty string

This commit is contained in:
Matthew Flatt 2015-10-05 13:28:53 -06:00
parent d988055a49
commit c9c03dd40b
2 changed files with 5 additions and 1 deletions

View File

@ -1121,6 +1121,8 @@
(test "x&cy&z" regexp-replace* #rx"a(.)" "xabcyawz" "\\&")
(test "x\\cy\\z" regexp-replace* #rx"a(.)" "xabcyawz" "\\\\")
(test "ap0p0le" regexp-replace* #rx"p" "apple" "\\0\\$0")
;; Test sub-matches with procedure replace (second example by synx)
(test "myCERVEZA myMI Mi"
regexp-replace* "([Mm])i ([a-zA-Z]*)" "mi cerveza Mi Mi Mi"

View File

@ -410,7 +410,9 @@
(or (and (equal? (char->integer #\&) next)
#"&")
(and (equal? (char->integer #\\) next)
#"\\")))
#"\\")
(and (equal? (char->integer #\$) next)
#"")))
=> (lambda (s)
(cons s (loop (add1 (cdar m)))))]
[else