I have to remove all spaces between number and percentage sign. String can contain all other symbols as well. Space should be removed only between number and percentage not any other symbol and percentage.
Examples:
str = "test 12 %"; // expected "test 12%"
str = "test 1.2 %"; // expected "test 1.2%"
str = "test 1,2 % 2.5 %"; // expected "test 1,2% 2.5%"
str = " % test 1,2 % 2.5 % something"; // expected " % test 1,2% 2.5% something"
I think that I have managed to create regexp that matches "decimal number with percentage sign", however, I do not know how to do "replace space in this matching number".
var r = /\(?\d+(?:\.\d+)? ?%\)? */g;