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

31
LINES

< > BotCompany Repo | #1033230 // dropSpaceEtc

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3841L/22K).

sS dropSpaceEtc(S s) {
  elegant {
    ret filterChars(c -> !isSpaceEtc(c), s);
  } inlined {
    replace test with !isSpaceEtc .
    
    if (empty(s)) null;
    int n = l(s), i = 0;
    char c = s.charAt(i);
    bool totality = test(c);
    for (++i; i < n; i++) {
      c = s.charAt(i);
      bool b = test(c);
      
      if (b != totality) {
        // diverse case
        new StringBuilder buf;
        if (totality) buf.append(substring(s, 0, i));
        while ping (true) {
          if (b) buf.append(c);
          if (++i >= n) break;
          c = s.charAt(i);
          b = test(c);
        }
        ret buf.toString();
      }
    }
      
    ret totality ? s : "";
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033230
Snippet name: dropSpaceEtc
Eternal ID of this version: #1033230/2
Text MD5: ca2dac2fa0167b86c8a1eb627dd7ce5a
Transpilation MD5: 14513bc3ef903e52cd347809d1bf4f8f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-16 07:33:27
Source code size: 719 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 90 / 146
Version history: 1 change(s)
Referenced in: [show references]