Clarify `regexp-split' on an empty input.
The text that says that (regexp-split #rx"whatever" "") returns '("") rather than '() is If `input' contains no matches [...] the result is a list containing input’s content [...] as a single element. This is a little implicit, if you consider such an input as having nothing left to match over so it's as if there is no input (with a port this confusion is a little clearer). Clarify with an example in the docs, and also add tests.
This commit is contained in:
parent
6318df82e5
commit
dcf2754a57
|
@ -785,6 +785,7 @@ an end-of-file if @racket[input] is an input port).
|
||||||
(regexp-split #rx"" "12 34")
|
(regexp-split #rx"" "12 34")
|
||||||
(regexp-split #rx" *" "12 34")
|
(regexp-split #rx" *" "12 34")
|
||||||
(regexp-split #px"\\b" "12, 13 and 14.")
|
(regexp-split #px"\\b" "12, 13 and 14.")
|
||||||
|
(regexp-split #rx" +" "")
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@;------------------------------------------------------------------------
|
@;------------------------------------------------------------------------
|
||||||
|
|
|
@ -311,6 +311,9 @@
|
||||||
(t '("" "" " " "" "" "") eof " *" "12 34")
|
(t '("" "" " " "" "" "") eof " *" "12 34")
|
||||||
(t '(" " "" "" " " "" "" " " "") eof " *" " 12 34 ")
|
(t '(" " "" "" " " "" "" " " "") eof " *" " 12 34 ")
|
||||||
(t '("" "" " " "" "" "") " " " *" " 12 34 " 1 6)
|
(t '("" "" " " "" "" "") " " " *" " 12 34 " 1 6)
|
||||||
|
(t '("") eof " *" "")
|
||||||
|
(t '("") eof " *" "1234" 4)
|
||||||
|
(t '("") "34" " *" "1234" 2 2)
|
||||||
(t regexp-match-positions*)
|
(t regexp-match-positions*)
|
||||||
(t '((0 . 0) (1 . 1) (2 . 2) (3 . 3)) eof "" "123")
|
(t '((0 . 0) (1 . 1) (2 . 2) (3 . 3)) eof "" "123")
|
||||||
(t '((0 . 0) (1 . 1) (2 . 3) (3 . 3) (4 . 4) (5 . 5)) eof " *" "12 34")
|
(t '((0 . 0) (1 . 1) (2 . 3) (3 . 3) (4 . 4) (5 . 5)) eof " *" "12 34")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user