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

11
LINES

< > BotCompany Repo | #1016329 // stringToLegalIdentifier

JavaX fragment (include)

static S stringToLegalIdentifier(S s) {
  new StringBuilder buf;
  s = dropTrailingSquareBracketStuff(s);
  for i over s: {
    char c = s.charAt(i);
    if (empty(buf) ? Character.isJavaIdentifierStart(c) : Character.isJavaIdentifierPart(c))
      buf.append(c);
  }
  if (empty(buf)) fail("Can't convert to legal identifier: " + s);
  ret str(buf);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016329
Snippet name: stringToLegalIdentifier
Eternal ID of this version: #1016329/3
Text MD5: 490617db697a95fba6d08a442761d734
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-20 15:17:33
Source code size: 362 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 372
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)