Libraryless. Click here for Pure Java version (2725L/17K).
1 | // f takes variable without $ sign. if it returns null, variable is kept |
2 | sS replaceDollarVars_dyn(S s, IF1<S> f) {
|
3 | if (f == null) ret s; |
4 | ret regexpReplaceIC(s, "\\$(\\w+)", matcher -> {
|
5 | S var = matcher.group(1); |
6 | S val = f.get(var); |
7 | ret val == null ? matcher.group() : str(val); |
8 | }); |
9 | } |
Began life as a copy of #1028680
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1030433 |
| Snippet name: | replaceDollarVars_dyn - does not use a tokenizer |
| Eternal ID of this version: | #1030433/1 |
| Text MD5: | 7b86bc8bb41da08e4f7aed4d6fece1ed |
| Transpilation MD5: | b9d295ae79cb239151c98e2527f7580a |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-12-16 23:12:31 |
| Source code size: | 309 bytes / 9 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 548 / 683 |
| Referenced in: | [show references] |