Regular how to remove the left and right spaces of specified characters in a string

for example: "aa A1:B2 v2VR b3"
want to get: "aa A1:B2 v2VR b3"


var str = 'aa A1: B2 v2 : b3';
var reg = /(\s*:\s*)+/gi;
var newstr = str.replace(reg, ':');
console.log(newstr);

clipboard.png

Menu