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

14
LINES

< > BotCompany Repo | #1034740 // starFormat - simple formatter replacing * with each argument (no tokenizing)

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

Libraryless. Click here for Pure Java version (5330L/29K).

1  
sS starFormat(S pat, O... args) {
2  
  int n = l(pat), iArg = 0, iChar = 0;
3  
  new StringBuilder buf;
4  
  while true {
5  
    int jChar = smartIndexOf(pat, iChar, '*');
6  
    buf.append(substring(pat, iChar, jChar));
7  
    
8  
    if (jChar >= n) break;
9  
    buf.append(str(get(args, iArg++)));
10  
    iChar = jChar+1;
11  
  }
12  
  
13  
  ret str(buf);
14  
}

Author comment

Began life as a copy of #1026690

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034740
Snippet name: starFormat - simple formatter replacing * with each argument (no tokenizing)
Eternal ID of this version: #1034740/6
Text MD5: 7c8ce41d4efe94a99f4317a0ca0728a6
Transpilation MD5: 765caaadcd55dbd5fe287e0dbc506d0c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 01:50:39
Source code size: 336 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 85 / 144
Version history: 5 change(s)
Referenced in: [show references]