In string n+n(n+n), where n stands for any number or digit, I'd like to match ( and replace it by *(, but only if it is followed by a number or digit.
Examples:
- I'd like to change
2+22(2+2)into2+22*(2+2), - I'd like to change
-1(3)into-1*(3), 4+(5/6)should stay as it is.
This is what I have:
var str = '2+2(2+2)'.replace(/^[0-9]\(/g, '*(');
But it doesn't work. Thanks in advance.