const UseMaskZip = (zip: string) => { let x = zip .toString() .replace(/\D/g, '') .match(/(\d{0,5})/); if (x) { return x[0]; } else { return 'invalid phone number'; } }; export default UseMaskZip;