Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1004456 // splitAt - split string at literal substring

JavaX fragment (include)

// TODO: returns empty first, but not empty last
static L<S> splitAt(S s, S splitter) {
  if (empty(splitter)) null; // avoid endless loop
  new L<S> parts;
  int i = 0;
  if (s != null)
    while (i < l(s)) {
      int j = indexOf(s, splitter, i);
      if (j < 0) j = l(s);
      parts.add(substring(s, i, j));
      i = j+l(splitter);
    }
  ret parts;
}

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: 544 / 604
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024605 - splitAt_withEmptyLast - split string at literal substring [dev.]
#1029813 - splitAtEquals