Libraryless. Click here for Pure Java version (55L/1K).
static S substring(S s, int x) { ret substring(s, x, strL(s)); } static S substring(S s, int x, int y) { if (s == null) return null; if (x < 0) x = 0; int n = s.length(); if (y < x) y = x; if (y > n) y = n; if (x >= y) ret ""; return s.substring(x, y); } ifclass IntRange static S substring(S s, IntRange r) { ret r == null ? null : substring(s, r.start, r.end); } endif // convenience method for quickly dropping a prefix sS substring(S s, CharSequence l) { ret substring(s, lCharSequence(l)); }
Began life as a copy of #1001853
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1002637 |
| Snippet name: | substring - exception-free (safe) version of String.substring |
| Eternal ID of this version: | #1002637/14 |
| Text MD5: | 4bd5f88c94b2e6c19242cf331151bba1 |
| Transpilation MD5: | 46704d4744af4e00e5e182bab6ca5db8 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-05-06 16:11:54 |
| Source code size: | 542 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1604 / 3009 |
| Version history: | 13 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1008850 - trimSubstring - trim of substring #1012683 - subsymbol #1028010 - substringWithLength - substring() but second parameter is length #1029174 - substringFromCharArray #1029258 - substringObject #1031138 - Smarty AI Include #3000382 - Answer for ferdie (>> t = 1, f = 0) |