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

18
LINES

< > BotCompany Repo | #1022429 // splitCamelCasePlusUnderscores (keeps the underscores)

JavaX fragment (include)

static L<S> splitCamelCasePlusUnderscores(S s) {
  int j = 0;
  new L<S> l;
  
  // new addition
  if (isAllUpperCase(s)) ret l with l.add(s);
  
  for i over s: {
    char last = charAt(s, i-1), c = s.charAt(i);
    if (i > j && (isUpperCaseLetter(c) || last == '_' || c == '_')) {
      l.add(substring(s, j, i));
      j = i;
    }
  }
  if (j < l(s))
    l.add(substring(s, j));
  ret l;
}

Author comment

Began life as a copy of #1012527

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022429
Snippet name: splitCamelCasePlusUnderscores (keeps the underscores)
Eternal ID of this version: #1022429/3
Text MD5: d43bd962b4b4f72272dd2b7b85296898
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-17 10:56:20
Source code size: 410 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 174 / 209
Version history: 2 change(s)
Referenced in: [show references]