export function phoneSeparated(phoneNumber) { if (!phoneNumber) { return null; } let tel = phoneNumber.replace(/(^\s+)|(\s+$)/g, ‘‘); tel = tel.replace(/\s/g, ‘‘); if (!tel) { return null; } if (tel.length === 11) { tel = tel.substring(0, 3) + ‘-‘ + tel.substring(3, 7) + ‘-‘ + tel.substring(7, 11); } else if (tel.length === 12) { tel = tel.substring(0, 4) + ‘ ‘ + tel.substring(4, 8) + ‘-‘ + tel.substring(8, 12); } return tel; }