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

10
LINES

< > BotCompany Repo | #1036401 // onlyChars

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

Libraryless. Click here for Pure Java version (9902L/55K).

1  
sS onlyChars(S chars, S s) {
2  
  if (empty(chars)) ret "";
3  
  int n = l(s);
4  
  new StringBuilder buf;
5  
  char c;
6  
  for i to n:
7  
    if (contains(chars, c = s.charAt(i)))
8  
      buf.append(c);
9  
  ret str(buf);
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036401
Snippet name: onlyChars
Eternal ID of this version: #1036401/1
Text MD5: c61bf87759ec7eb8bb7c5b24f714a04e
Transpilation MD5: 1f019dc9180bff19de61f8369b530510
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-08 01:34:49
Source code size: 211 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 115 / 168
Referenced in: [show references]