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

17
LINES

< > BotCompany Repo | #1010927 // dropLeadingPunctuation

JavaX fragment (include)

static L<S> dropLeadingPunctuation_keep = ll("*", "<", ">", "(", "{", "[");

static L<S> dropLeadingPunctuation(L<S> tok) {
  tok = new ArrayList<S>(tok);
  for (int i = 1; i < l(tok); ) {
    S t = tok.get(i);
    if (eq(t, "...") || t.length() == 1 && !Character.isLetterOrDigit(t.charAt(0)) && !dropLeadingPunctuation_keep.contains(t)) {
      tok.remove(i);
      tok.remove(i);
    } else break;
  }
  return tok;
}

static S dropLeadingPunctuation(S s) {
  ret join(dropLeadingPunctuation(nlTok(s)));
}

Author comment

Began life as a copy of #1008344

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, whxojlpjdney

No comments. add comment

Snippet ID: #1010927
Snippet name: dropLeadingPunctuation
Eternal ID of this version: #1010927/4
Text MD5: 8ed26597f13e67080faa0cb715716ff0
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-06 10:25:44
Source code size: 524 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 430 / 459
Version history: 3 change(s)
Referenced in: [show references]