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

14
LINES

< > BotCompany Repo | #1024605 // splitAt_withEmptyLast - split string at literal substring [dev.]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1656L/11K).

static L<S> splitAt_withEmptyLast(S s, S splitter) {
  new L<S> parts;
  if (nempty(s)) {
    int i = 0;
    while (i < l(s)) {
      int j = indexOf(s, splitter, i);
      if (j < 0) break;
      parts.add(substring(s, i, j));
      i = j+l(splitter);
    }
    parts.add(substring(s, i));
  }
  ret parts;
}

Author comment

Began life as a copy of #1004456

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024605
Snippet name: splitAt_withEmptyLast - split string at literal substring [dev.]
Eternal ID of this version: #1024605/3
Text MD5: bde9d142cd5d66d0d32a02f94156a83d
Transpilation MD5: 409c04e3075a4d966001708ddd9b8883
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-19 21:25:48
Source code size: 322 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 255
Version history: 2 change(s)
Referenced in: [show references]