fix regexp-replace*
This commit is contained in:
parent
9eaa749f5e
commit
9ca5f6b340
|
@ -328,9 +328,8 @@
|
||||||
"expected a byte string result: ")
|
"expected a byte string result: ")
|
||||||
v))
|
v))
|
||||||
v))
|
v))
|
||||||
(define rx:sub #rx#"^(?:[^&\\]*[\\][&\\])*[^&\\]*(?:&|[\\](?=[^&\\]|$))")
|
|
||||||
(define need-replac? (and (not (procedure? replacement))
|
(define need-replac? (and (not (procedure? replacement))
|
||||||
(regexp-match? rx:sub replacement)))
|
(regexp-match? #rx#"[\\&]" replacement)))
|
||||||
(define (replac ms str)
|
(define (replac ms str)
|
||||||
(if need-replac?
|
(if need-replac?
|
||||||
((if (string? str) bytes->string/utf-8 values)
|
((if (string? str) bytes->string/utf-8 values)
|
||||||
|
|
|
@ -1071,6 +1071,8 @@
|
||||||
(test "==1=2===3==4==" regexp-replace* "2*" "1234" (lambda (s) (string-append "=" s "=")))
|
(test "==1=2===3==4==" regexp-replace* "2*" "1234" (lambda (s) (string-append "=" s "=")))
|
||||||
|
|
||||||
(test "x&b\\ab=cy&w\\aw=z" regexp-replace* #rx"a(.)" "xabcyawz" "\\&\\1\\\\&\\99=")
|
(test "x&b\\ab=cy&w\\aw=z" regexp-replace* #rx"a(.)" "xabcyawz" "\\&\\1\\\\&\\99=")
|
||||||
|
(test "x&cy&z" regexp-replace* #rx"a(.)" "xabcyawz" "\\&")
|
||||||
|
(test "x\\cy\\z" regexp-replace* #rx"a(.)" "xabcyawz" "\\\\")
|
||||||
|
|
||||||
;; Test weird port offsets:
|
;; Test weird port offsets:
|
||||||
(define (test-weird-offset regexp-match regexp-match-positions)
|
(define (test-weird-offset regexp-match regexp-match-positions)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user