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

14
LINES

< > BotCompany Repo | #1027764 // formatWithFragments

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

Libraryless. Click here for Pure Java version (2732L/17K).

1  
sO formatWithFragments(S starPattern, O... args) {
2  
  L tok = javaTok(starPattern);
3  
  int iArg = 0, i = 1;
4  
  new L out;
5  
  while (i < l(tok)) {
6  
    int j = smartIndexOf(tok, i, "*");
7  
    if (j > i)
8  
      out.add(Fragment(joinSubList(tok, i, j-1)));
9  
    if (j < l(tok))
10  
      out.add(args[iArg++]);
11  
    i = j+2;
12  
  }
13  
  ret l(out) == 1 ? first(out) : out;
14  
}

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: #1027764
Snippet name: formatWithFragments
Eternal ID of this version: #1027764/6
Text MD5: 7ca431a0b379adbefc3b44d7086f47eb
Transpilation MD5: f11855abb3ce598ebd18911ae200fff9
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-10 02:16:55
Source code size: 365 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 236 / 383
Version history: 5 change(s)
Referenced in: [show references]