var str = '123.456'.replace(/(\d+)(?=\.\d+)/, function(a, b) { return a.split('').join(' '); }); alert(str);