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

14
LINES

< > BotCompany Repo | #1003360 // splitAtEmptyLines - also covers lines containing spaces

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

Libraryless. Click here for Pure Java version (2738L/17K).

1  
static L<S> splitAtEmptyLines(S text) {
2  
  L<S> lines = toLines(text);
3  
  int n = l(lines), i = 0;
4  
  new L<S> parts;
5  
  while ping (true) {
6  
    while (i < n && emptyAfterTrim(lines.get(i))) ++i;
7  
    if (i >= n) break;
8  
    int j = i;
9  
    while (j < n && !emptyAfterTrim(lines.get(j))) ++j;
10  
    parts.add(fromLines(subList(lines, i, j)));
11  
    i = j;
12  
  }
13  
  ret parts;
14  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1003360
Snippet name: splitAtEmptyLines - also covers lines containing spaces
Eternal ID of this version: #1003360/3
Text MD5: 495efd68ec9496749f7515dddd7684ae
Transpilation MD5: 5a99d8f55c758aaca57ce287df324892
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-18 11:35:13
Source code size: 376 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 660 / 721
Version history: 2 change(s)
Referenced in: [show references]