I was trying to use lookaheads in my code to try to apply a function to all numbers in a string, but when I tried to add a lookahead to prevent random words with numbers in them (like models of things) the regex only gets the last whole interger (in this case, 9) and adds the decimals. I assume I'm doing something wrong with adding the lookahead, but I couldnt find anything on it. The length of the numbers varies, so using curly brackets isn't an option. What am I doing wrong?
e = "59.84"
ea = e.replace(/(?!\w\-*\d+\.?\d*\w)\-?\d+\.*\d*/g, v => v * 2 );
console.log(ea)/*logs... 519.68???
5 + 9.84 * 2
*/
e = "59.84"
ea = e.replace(/\-?\d+\.?\d*/g, v => v * 2 );
console.log(ea)/*logs 119.68*/