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)

static L<S> splitAtEmptyLines(S text) {
  L<S> lines = toLines(text);
  int n = l(lines), i = 0;
  new L<S> parts;
  while true {
    while (i < n && emptyAfterTrim(lines.get(i))) ++i;
    if (i >= n) break;
    int j = i;
    while (j < n && !emptyAfterTrim(lines.get(j))) ++j;
    parts.add(fromLines(subList(lines, i, j)));
    i = j;
  }
  ret parts;
}

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1003360
Snippet name: splitAtEmptyLines - also covers lines containing spaces
Eternal ID of this version: #1003360/2
Text MD5: 734ed546ab75085f232ebd703858239d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-20 13:38:18
Source code size: 369 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 399 / 383
Version history: 1 change(s)
Referenced in: [show references]