Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1001735 // unquote - opposite of quote. also takes single quoted strings

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9132L/50K).

1  
sS unquote(S s) {
2  
  if (s == null) null;
3  
  if (startsWith(s, '[')) {
4  
    int i = 1;
5  
    while (i < s.length() && s.charAt(i) == '=') ++i;
6  
    if (i < s.length() && s.charAt(i) == '[') {
7  
      String m = s.substring(1, i);
8  
      if (s.endsWith("]" + m + "]"))
9  
        return s.substring(i+1, s.length()-i-1);
10  
    }
11  
  }
12  
  ret unquoteSingleOrDoubleQuotes(s);
13  
}

Author comment

Began life as a copy of #2000521

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001735
Snippet name: unquote - opposite of quote. also takes single quoted strings
Eternal ID of this version: #1001735/14
Text MD5: b5a492cd9e171729842a2b4ceda1e31e
Transpilation MD5: 3ab37a13cb220a8bcc389728ca45f592
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-31 04:01:54
Source code size: 369 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 1052 / 9723
Version history: 13 change(s)
Referenced in: [show references]