Libraryless. Click here for Pure Java version (4079L/24K).
1 | static LS javaTok_simpleSpacesAndTrim(S s) { |
2 | ret javaTok_simpleSpacesAndTrim(javaTok(s)); |
3 | } |
4 | |
5 | static LS javaTok_simpleSpacesAndTrim(LS tok) { |
6 | int n = l(tok); |
7 | for (int i = 0; i < n; i += 2) { |
8 | int nIdx = i; |
9 | S space = tok.get(nIdx); |
10 | S prev = get(tok, nIdx-1), next = get(tok, nIdx+1); |
11 | |
12 | if (empty(space)) // no space anyway? keep that |
13 | space = ""; |
14 | else if (prev == null || next == null) // end of string - no spaces either |
15 | space = ""; |
16 | else if (isBracket(prev) && isBracket(next)) |
17 | space = ""; |
18 | |
19 | tok.set(i, space); |
20 | } |
21 | ret tok; |
22 | } |
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: | #1028757 |
Snippet name: | javaTok_simpleSpacesAndTrim |
Eternal ID of this version: | #1028757/8 |
Text MD5: | 182b99c7abef171beafa74a5789293c4 |
Transpilation MD5: | 9e70e093086d24b333ff363b9c2172fd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-11 10:21:53 |
Source code size: | 607 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 221 / 318 |
Version history: | 7 change(s) |
Referenced in: | [show references] |