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