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   

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

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: 126 / 142
Version history: 2 change(s)
Referenced in: [show references]

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