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

9
LINES

< > BotCompany Repo | #1025045 // re-implemented trim [dev.]

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

Libraryless. Click here for Pure Java version (55L/1K).

sS trim(S s) {
  if (s == null) null;
  int i = 0, n = s.length(), j = n;
  while (i < n && " \t\r\n".indexOf(s.charAt(i)) >= 0)
    ++i;
  while (j > i && " \t\r\n".indexOf(s.charAt(j-1)) >= 0)
    --j;
  ret substring(s, i, j);
}

Author comment

Began life as a copy of #1001543

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025045
Snippet name: re-implemented trim [dev.]
Eternal ID of this version: #1025045/5
Text MD5: 0f1284d4bf0d523192e124257ceff671
Transpilation MD5: c511ff97daa44cfdadf59780914a547b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-03 14:26:06
Source code size: 239 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 151 / 224
Version history: 4 change(s)
Referenced in: [show references]