So I want to match in string bellow, which will be formula for excell/ spreadsheet type cell, all addresses: \w+\d+ , and change numbers only number part in them. I want to get following strings from original: "= A2 + B2", "=A3+B3", "=A4+B4" ...
I tried:
const a = "=A1 + B1"
for (let i = 0; i < 100 ; i++) {
const b = a.replace(/\w+$(\d+)/g, String(i + 1));
console.log(b)
}
and it gives result:
then if I do without $ before grouping () parentesis:
const a = "=A1 + B1"
for (let i = 0; i < 100 ; i++) {
const b = a.replace(/\w+(\d+)/g, String(i + 1));
console.log(b)
}
I get:



"=A1 + B1", what result do you want?"=A27 + B42"becomes="A1 + B1",="A2 + B2", etc.?=A1 + B1, and it will be adapted for differant cell adresses with this regex.