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

29
LINES

< > BotCompany Repo | #1017544 - splitAtTokens

JavaX fragment (include)

static L<S> splitAtTokens(S s, LS tokens) {
  ret splitAtTokens(javaTok(s), tokens);
}

static L<S> splitAtTokens(L<S> tok, LS tokens) {
  new L<S> l;
  int i = 0;
  while (i < l(tok)) {
    int j = indexOfSubList(tok, tokens, i);
    if (i >= l(tok)) break;
    if (j < 0) j = l(tok);
    l.add(trimJoin(tok.subList(i, j)));
    i = j+l(tokens);
  }
  ret l;
}

static L<S> splitAtTokens(L<S> tok, S... tokens) {
  new L<S> l;
  int i = 0;
  while (i < l(tok)) {
    int j = indexOfSubList(tok, tokens, i);
    if (i >= l(tok)) break;
    if (j < 0) j = l(tok);
    l.add(trimJoin(tok.subList(i, j)));
    i = j+l(tokens);
  }
  ret l;
}

Author comment

Began life as a copy of #1011989

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1017544
Snippet name: splitAtTokens
Eternal ID of this version: #1017544/3
Text MD5: acd1b1307e488e0692e664d6b3380989
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-03 19:57:39
Source code size: 666 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 237 / 230
Version history: 2 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1017544 & http://1017544.tinybrain.de