'vscode regex sub match evaluate instead of concatenate?
Test 300
Test 301
Test 302
I can use regex find to loop through these:
Test (3[0-9]*)
When I try replace with math it concatenates instead of evaluates?
Test $1-100
So, it becomes:
Test 300-100
Is it possible to evaluate instead of concatenate, so it becomes:
Test 200
Thanks.
Solution 1:[1]
There are more extensions that can do this now, including one I wrote Find and Transform.
With this keybinding:
{
"key": "alt+m", // whatever keybinding you want
"command": "findInCurrentFile",
"args": {
"find": "(?<=Test\\s)(3\\d\\d)", // get 300+ in capture group 1
"replace": "$${ return $1 - 100 }", // subtract 100 from capture group 1
"isRegex": true
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

