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

6
LINES

< > BotCompany Repo | #1005181 // dropLastLine

JavaX fragment (include)

// if text trails with \n, drops the line before that
static S dropLastLine(S s) {
  s = dropSuffix("\r", dropSuffix("\n", s));
  int i = s.lastIndexOf('\n');
  ret i < 0 ? "" : dropSuffix("\r", substring(s, 0, i));
}

Author comment

Began life as a copy of #1001797

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005181
Snippet name: dropLastLine
Eternal ID of this version: #1005181/1
Text MD5: 8742586e1633587c836afcfb481c35b1
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-19 15:16:39
Source code size: 222 bytes / 6 lines
Pitched / IR pitched: No / No
Views / Downloads: 546 / 541
Referenced in: [show references]