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

11
LINES

< > BotCompany Repo | #1016329 - stringToLegalIdentifier

JavaX fragment (include)

1  
static S stringToLegalIdentifier(S s) {
2  
  new StringBuilder buf;
3  
  s = dropTrailingSquareBracketStuff(s);
4  
  for i over s: {
5  
    char c = s.charAt(i);
6  
    if (empty(buf) ? Character.isJavaIdentifierStart(c) : Character.isJavaIdentifierPart(c))
7  
      buf.append(c);
8  
  }
9  
  if (empty(buf)) fail("Can't convert to legal identifier: " + s);
10  
  ret str(buf);
11  
}

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

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