var text = 11111111; var reg = /^(\d{2})(\d{2})(\d+)/ var formated = text.replace(reg, '$1' + '.' + '$2' + '.' + '$3');