formatPhoneNumber
문자열
을 입력하면 전화 번호 포맷
으로 -(hyphen)
을 넣어서 반환해주는 함수입니다.
Code
Interface
typescript
const formatPhoneNumber: (value: string) => string
Usage
typescript
import { formatPhoneNumber } from '@modern-kit/utils';
const phoneNumber0 = formatPhoneNumber('03112345678'); // '031-1234-5678'
const phoneNumber1 = formatPhoneNumber('01012345678'); // '010-1234-5678'
const phoneNumber2 = formatPhoneNumber('021231234'); // '02-123-1234'
const phoneNumber2 = formatPhoneNumber('(02)12351234'); // '02-1235-1234'
const phoneNumber3 = formatPhoneNumber('12334788'); // '1233-4788'