var str = \'asd-0.testing\'; var regex = /asd-(\\d)\\.\\w+/; str.replace(regex, 1);
That replaces the entire string str with
str
I think the simplest way to achieve your goal is this:
var str = 'asd-0.testing'; var regex = /(asd-)(\d)(\.\w+)/; var anyNumber = 1; var res = str.replace(regex, `$1${anyNumber}$3`);