I am trying to replace the last number of each match in between parenthesis.
so if I had cos(3 * 3)
before this regex
result = result.replace(/\d+(?:\.\d+)?/g, x => `${x}deg`)
would turn cos(3 * 3) into cos(3deg * 3deg)
I need only the last number to be changed to deg
So if I had cos(3 * 3) + cos(3 * 2) it would be cos(3 * 3deg) + cos(3 * 2deg)
What regular expression magic could I use to do this.
\d+(?=\s?\))This will match any numeral before closing brackets.