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.
You can use the VS Code Super Replace extension to achieve this.
Find field is the regular expression
Replace is the replace expression. Sub match with $$index
syntax will be resolved using the function in Processing function field
Here is an example of use that answers your question :
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With