File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -108,9 +108,10 @@ let split ~rex s =
108
108
in
109
109
match Re. exec rex s ~pos: 0 with
110
110
| g ->
111
- if Group. start g 0 = 0
112
- then List. rev (split [] (Group. stop g 0 ))
113
- else split [ String. sub s 0 (Group. start g 0 ) ] (Group. stop g 0 )
111
+ List. rev
112
+ (if Group. start g 0 = 0
113
+ then split [] (Group. stop g 0 )
114
+ else split [ String. sub s 0 (Group. start g 0 ) ] (Group. stop g 0 ))
114
115
| exception Not_found -> if s = " " then [] else [ s ]
115
116
;;
116
117
Original file line number Diff line number Diff line change @@ -4,17 +4,17 @@ let split ~rex s = Re.Pcre.split ~rex s |> strings
4
4
5
5
let % expect_test " split" =
6
6
split ~rex: re_whitespace " aa bb c d " ;
7
- [% expect {| [" d " ; " c " ; " bb " ; " aa " ] | }];
7
+ [% expect {| [" aa " ; " bb " ; " c " ; " d " ] | }];
8
8
split ~rex: re_whitespace " a full_word bc " ;
9
9
[% expect {| [" a" ; " full_word" ; " bc" ] | }];
10
10
split ~rex: re_empty " abcd" ;
11
11
[% expect {| [" a" ; " b" ; " c" ; " d" ] | }];
12
12
split ~rex: re_eol " a\n b" ;
13
- [% expect {| [" \n b " ; " a " ] | }];
13
+ [% expect {| [" a " ; " \n b " ] | }];
14
14
split ~rex: re_bow " a b" ;
15
15
[% expect {| [" a " ; " b" ] | }];
16
16
split ~rex: re_eow " a b" ;
17
- [% expect {| [" b " ; " a " ] | }];
17
+ [% expect {| [" a " ; " b " ] | }];
18
18
let rex = Re.Pcre. regexp " " in
19
19
split ~rex " xx" ;
20
20
[% expect {| [" x" ; " x" ] | }]
You can’t perform that action at this time.
0 commit comments