Libraryless. Click here for Pure Java version (2474L/16K).
1 | static S substring(S s, int x) { |
2 | ret substring(s, x, strL(s)); |
3 | } |
4 | |
5 | static S substring(S s, int x, int y) { |
6 | if (s == null) return null; |
7 | if (x < 0) x = 0; |
8 | int n = s.length(); |
9 | if (y < x) y = x; |
10 | if (y > n) y = n; |
11 | if (x >= y) ret ""; |
12 | return s.substring(x, y); |
13 | } |
14 | |
15 | ifclass IntRange |
16 | static S substring(S s, IntRange r) { |
17 | ret r == null ? null : substring(s, r.start, r.end); |
18 | } |
19 | endif |
20 | |
21 | // convenience method for quickly dropping a prefix |
22 | sS substring(S s, CharSequence l) { |
23 | ret substring(s, l(l)); |
24 | } |
Began life as a copy of #1001853
download show line numbers debug dex
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1002637 |
Snippet name: | substring - exception-free (safe) version of String.substring |
Eternal ID of this version: | #1002637/13 |
Text MD5: | e98b450b6054e8b2a672fe101695b8a9 |
Transpilation MD5: | 7e4c9a912f6ce02e05a123b2bebce91d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-01 22:41:41 |
Source code size: | 530 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 534 / 1247 |
Version history: | 12 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1002637 & http://1002637.tinybrain.de