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

17
LINES

< > BotCompany Repo | #1020948 - jreplace_multi

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

Libraryless. Click here for Pure Java version (2813L/18K).

sbool jreplace_multi(LS tok, LS ins, S out) {
  bool change = false;
  for (S in : ins)
    if (jreplace(tok, in, out))
      change = true;
  ret change;
}

// doesn't loop
sS jreplace_multi(S s, S... replacements) {
  LS tok = javaTok(s);
  bool change;
  for (int i = 0; i < l(replacements); i += 2)
    if (jreplace(tok, replacements[i], replacements[i+1]))
      set change;
  ret change ? join(tok) : s;
}

download  show line numbers  debug dex   

Travelled to 4 computer(s): cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1020948
Snippet name: jreplace_multi
Eternal ID of this version: #1020948/5
Text MD5: a8dd6c3f718822099c2b1c56a5bbc79e
Transpilation MD5: f97e807df5a0238afd6ecf5c1a1d5da3
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-27 16:38:00
Source code size: 427 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 80 / 104
Version history: 4 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1020948 & http://1020948.tinybrain.de