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

22
LINES

< > BotCompany Repo | #1033108 // tok_splitAtAnyOperator [seems to work]

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

Transpiled version (4097L) is out of date.

static LS tok_splitAtAnyOperator(S s) {
  ret tok_splitAtAnyOperator(javaTok(s));
}

static LS tok_splitAtAnyOperator(LS tok) {
  new LS l;
  int i = 1;
  while ping (i < l(tok)) {
    S t;
    int lastI = i, j = i;
    while (l(t = get(tok, j)) == 1 && !startsWithLetterOrDigit(t))
      j += 2;
    addIfNempty(l, trimJoinSubList(tok, i, j));
    i = j;
    while (j < l(tok) && !(l(t = get(tok, j)) == 1 && !startsWithLetterOrDigit(t)))
      j += 2;
    addIfNempty(l, trimJoinSubList(tok, i, j));
    i = j;
    assertTrue("safety", i > lastI);
  }
  ret l;
}

Author comment

Began life as a copy of #1017544

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033108
Snippet name: tok_splitAtAnyOperator [seems to work]
Eternal ID of this version: #1033108/7
Text MD5: c13836a9182c418aa66bb93c651f3c6f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-14 17:11:01
Source code size: 585 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 240
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)