1 | // TODO: returns empty first, but not empty last |
2 | static L<S> splitAt(S s, S splitter) { |
3 | if (empty(splitter)) null; // avoid endless loop |
4 | new L<S> parts; |
5 | int i = 0; |
6 | if (s != null) |
7 | while (i < l(s)) { |
8 | int j = indexOf(s, splitter, i); |
9 | if (j < 0) j = l(s); |
10 | parts.add(substring(s, i, j)); |
11 | i = j+l(splitter); |
12 | } |
13 | ret parts; |
14 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1004456 |
Snippet name: | splitAt - split string at literal substring |
Eternal ID of this version: | #1004456/2 |
Text MD5: | e9fab4a3e991a33223611bfd39fa2682 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-06-14 20:32:30 |
Source code size: | 371 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 644 / 713 |
Version history: | 1 change(s) |
Referenced in: | [show references] |