1 | // a must be trimmed |
2 | sS replaceLine_keepingPadding(S text, S a, S b) { |
3 | LS lines = lines(text); |
4 | bool change = false; |
5 | for i over lines: { |
6 | S s = lines.get(i); |
7 | S trimmed = trim(s); |
8 | if (eqic(trimmed, a)) { |
9 | int idx = indexOf(s, trimmed); |
10 | lines.set(i, replaceSubstring(s, idx, idx+l(trimmed), b)); |
11 | set change; |
12 | } |
13 | } |
14 | ret change ? lines_possiblyRTrim(text, lines) : text; |
15 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022519 |
Snippet name: | replaceLine_keepingPadding |
Eternal ID of this version: | #1022519/2 |
Text MD5: | 1ae94edbeacf8c90ba02298e745f2212 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-20 00:01:21 |
Source code size: | 420 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 278 / 282 |
Version history: | 1 change(s) |
Referenced in: | [show references] |