static S extractLastNLinesOfString(int n, S s) { int i = l(s)-1; // skip trailing new line if (i >= 0 && s.charAt(i) == '\n') --i; if (i >= 0 && s.charAt(i) == '\r') --i; while (n > 0 && i >= 0) { if (s.charAt(i) == '\n') if (--n == 0) break; --i; } ret substring(s, i+1); } static S extractLastNLinesOfString(S s, int n) { ret extractLastNLinesOfString(n, s); }
Began life as a copy of #1004746
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018865 |
Snippet name: | extractLastNLinesOfString |
Eternal ID of this version: | #1018865/5 |
Text MD5: | 40e3c29d35264ec8d81510581cb57273 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-14 18:06:21 |
Source code size: | 416 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 359 / 419 |
Version history: | 4 change(s) |
Referenced in: | [show references] |