Libraryless. Click here for Pure Java version (2735L/16K).
// f takes variable without $ sign. if it returns null, variable is kept sS replaceDollarVars2_dyn(S s, IF1<S> f) { if (f == null) ret s; ret regexpReplace(s, "\\$(\\w+)|\\$\\{(.+?)\\}", matcher -> { S var = or(matcher.group(1), matcher.group(2)); S val = f.get(var); ret val == null ? matcher.group() : str(val); }); }
Began life as a copy of #1030433
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030662 |
Snippet name: | replaceDollarVars2_dyn - does not use a tokenizer. also supports ${name} |
Eternal ID of this version: | #1030662/5 |
Text MD5: | 8c9bf832e4e5432e6b782ebf77931dfc |
Transpilation MD5: | aed7d5fc0803320e39cf8748f96596ab |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-02-22 13:09:43 |
Source code size: | 345 bytes / 9 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 213 / 393 |
Version history: | 4 change(s) |
Referenced in: | [show references] |