File tree 2 files changed +26
-14
lines changed
2 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -504,22 +504,21 @@ split: function [
504
504
return res
505
505
]
506
506
if at [
507
- return reduce either integer? dlm [
508
- [
509
- copy/part series dlm
510
- copy lib/at series dlm + 1
511
- ]
512
- ][
513
- ;-- Without adding a /tail refinement, we don't know if they want
514
- ; to split at the head or tail of the delimiter, so we'll exclude
515
- ; the delimiter from the result entirely. They know what the dlm
516
- ; was that they passed in, so they can add it back to either side
517
- ; of the result if they want to.
518
- [
519
- copy/part series find series :dlm
520
- copy find/tail series :dlm
507
+ unless integer? :dlm [
508
+ return reduce either dlm: find series :dlm [
509
+ dlm: index? dlm
510
+ [
511
+ copy/part series dlm - 1 ; excluding the delimiter
512
+ copy lib/at series dlm + 1
513
+ ]
514
+ ][
515
+ [copy series]
521
516
]
522
517
]
518
+ return reduce [
519
+ copy/part series dlm
520
+ copy lib/at series dlm + 1
521
+ ]
523
522
]
524
523
;print ['split 'parts? parts mold series mold dlm]
525
524
either all [block? dlm parse dlm [some integer! ]][
Original file line number Diff line number Diff line change @@ -2004,6 +2004,19 @@ Rebol [
2004
2004
;@@ https://github.com/Oldes/Rebol-issues/issues/690
2005
2005
--assert (split "This! is a. test? to see " charset "!?." ) = ["This" " is a" " test" " to see " ]
2006
2006
2007
+ --test-- "split/at"
2008
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/2490
2009
+ --assert (split/at "a:b" #":" ) = ["a" "b" ]
2010
+ --assert (split/at "a:b:c" #":" ) = ["a" "b:c" ]
2011
+ --assert (split/at "a" #":" ) = ["a" ]
2012
+ --assert (split/at "a:" #":" ) = ["a" "" ]
2013
+ --assert (split/at ":b" #":" ) = ["" "b" ]
2014
+ --assert (split/at [1 a 2 ] 'a) = [[1 ] [2 ]]
2015
+ --assert (split/at [1 a 2 3 ] 'a) = [[1 ] [2 3 ]]
2016
+ --assert (split/at [1 a 2 a 3 ] 'a) = [[1 ] [2 a 3 ]]
2017
+ --assert (split/at [1 2 ] 'a) = [[1 2 ]]
2018
+
2019
+
2007
2020
===end-group===
2008
2021
2009
2022
You can’t perform that action at this time.
0 commit comments