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

9
LINES

< > BotCompany Repo | #1028669 // replaceSquareBracketVars

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

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

1  
sS replaceSquareBracketVars(S s, O... params) {
2  
  if (empty(params)) ret s;
3  
  MapSO vars = mapKeys deSquareBracket((MapSO) litcimap(params));
4  
  ret regexpReplaceIC(s, "\\[(.+?)\\]", matcher -> {
5  
    S var = matcher.group(1);
6  
    O val = vars.get(var);
7  
    ret val == null ? matcher.group() : str(val);
8  
  });
9  
}

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: #1028669
Snippet name: replaceSquareBracketVars
Eternal ID of this version: #1028669/6
Text MD5: ebbdde2bcaa11e9bd272c2e91b83a1b5
Transpilation MD5: c47018881f27dc55ad1570e420b1174a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-11 15:23:35
Source code size: 317 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 217 / 348
Version history: 5 change(s)
Referenced in: [show references]