Libraryless. Click here for Pure Java version (2203L/14K).
1 | sS replace_multi(S s, Cl<S> a, S b) { |
2 | if (s == null || empty(a) || b == null) ret s; |
3 | for (S aa : a) |
4 | s = s.replace(aa, b); |
5 | ret s; |
6 | } |
7 | |
8 | // replacements = in, out, in, out, ... |
9 | sS replace_multi(S s, S... replacements) { |
10 | if (empty(s) || empty(replacements)) ret s; |
11 | for (int i = 0; i+1 < l(replacements); i += 2) |
12 | s = s.replace(replacements[i], replacements[i+1]); |
13 | ret s; |
14 | } |
Began life as a copy of #1007775
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: | #1026538 |
Snippet name: | replace_multi |
Eternal ID of this version: | #1026538/2 |
Text MD5: | e78eefc8c7b22e535addc542dda47fb8 |
Transpilation MD5: | a752cd8f536933ee046f8d7990c956a6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-11 18:42:18 |
Source code size: | 398 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 183 / 274 |
Version history: | 1 change(s) |
Referenced in: | [show references] |