Libraryless. Click here for Pure Java version (56L/1K).
sS shortenInTheMiddle(int max, CharSequence s) { if (s == null) ret ""; if (max < 0) ret str(s); if (s.length() <= max) ret str(s); S shortener = "..."; int m = max-shortener.length(); ret subCharSequence(s, 0, m-m/2) + shortener + subCharSequence(s, s.length()-m/2); }
Began life as a copy of #1000644
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029287 |
Snippet name: | shortenInTheMiddle |
Eternal ID of this version: | #1029287/5 |
Text MD5: | b3dc196ab8563286d5f82dc22753896d |
Transpilation MD5: | 7b7cbad7393df23df75ec42d7b2b37ac |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-29 22:52:37 |
Source code size: | 298 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 212 / 303 |
Version history: | 4 change(s) |
Referenced in: | [show references] |