From 357ff9f12aefe9e26dfda150ee5cd8ee2745f6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=B0=AC=ED=98=81?= Date: Sun, 14 Jul 2024 16:25:28 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AC=B8=EC=9E=90=EC=97=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=95=9C=EA=B8=80=EC=9D=84=20=EC=B6=94=EC=B6=9C?= =?UTF-8?q?=ED=95=B4=EC=A3=BC=EB=8A=94=20extractHangul=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=EB=A5=BC=20=EC=A0=9C=EA=B1=B0=ED=95=A9=EB=8B=88?= =?UTF-8?q?=EB=8B=A4=20(#185)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove extrachHangul * Create cyan-tigers-sneeze.md --------- Co-authored-by: Jonghyeon Ko --- .changeset/cyan-tigers-sneeze.md | 5 ++++ docs/src/pages/docs/api/extractHangul.en.md | 23 ------------------ docs/src/pages/docs/api/extractHangul.ko.md | 23 ------------------ src/extractHangul.spec.ts | 27 --------------------- src/extractHangul.ts | 18 -------------- src/index.ts | 1 - 6 files changed, 5 insertions(+), 92 deletions(-) create mode 100644 .changeset/cyan-tigers-sneeze.md delete mode 100644 docs/src/pages/docs/api/extractHangul.en.md delete mode 100644 docs/src/pages/docs/api/extractHangul.ko.md delete mode 100644 src/extractHangul.spec.ts delete mode 100644 src/extractHangul.ts diff --git a/.changeset/cyan-tigers-sneeze.md b/.changeset/cyan-tigers-sneeze.md new file mode 100644 index 00000000..931532d6 --- /dev/null +++ b/.changeset/cyan-tigers-sneeze.md @@ -0,0 +1,5 @@ +--- +"es-hangul": major +--- + +feat: 문자열에서 한글을 추출해주는 extractHangul 함수를 제거합니다 diff --git a/docs/src/pages/docs/api/extractHangul.en.md b/docs/src/pages/docs/api/extractHangul.en.md deleted file mode 100644 index c685c84a..00000000 --- a/docs/src/pages/docs/api/extractHangul.en.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: extractHangul ---- - -# extractHangul - -Extracts and returns only Korean characters from the string. - -For detailed examples, see below. - -```typescript -function extractHangul(str: string): string; -``` - -## Examples - -```tsx -extractHangul('안녕하세요1234abc'); // '안녕하세요' -extractHangul('abcde'); // '' -extractHangul('안녕하세요ㄱㄴ'); // '안녕하세요ㄱㄴ' -extractHangul('안녕하세요 만나서 반갑습니다'); // '안녕하세요 만나서 반갑습니다' -extractHangul('가나다!-29~라마바.,,사'); // '가나다라마바사' -``` diff --git a/docs/src/pages/docs/api/extractHangul.ko.md b/docs/src/pages/docs/api/extractHangul.ko.md deleted file mode 100644 index dc089bdb..00000000 --- a/docs/src/pages/docs/api/extractHangul.ko.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: extractHangul ---- - -# extractHangul - -문자열에서 한글만 추출하여 반환합니다. - -자세한 예시는 아래 Example을 참고하세요. - -```typescript -function extractHangul(str: string): string; -``` - -## Examples - -```tsx -extractHangul('안녕하세요1234abc'); // '안녕하세요' -extractHangul('abcde'); // '' -extractHangul('안녕하세요ㄱㄴ'); // '안녕하세요ㄱㄴ' -extractHangul('안녕하세요 만나서 반갑습니다'); // '안녕하세요 만나서 반갑습니다' -extractHangul('가나다!-29~라마바.,,사'); // '가나다라마바사' -``` diff --git a/src/extractHangul.spec.ts b/src/extractHangul.spec.ts deleted file mode 100644 index b3fd84dd..00000000 --- a/src/extractHangul.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { extractHangul } from './extractHangul'; - -describe('extractHangul', () => { - it('숫자와 알파벳과 특수문자를 제외한 한글 반환', () => { - expect(extractHangul('안녕하세요1234abc!@#')).toBe('안녕하세요'); - }); - - it('한글이 없는 문자열', () => { - expect(extractHangul('1234abc')).toBe(''); - }); - - it('한글과 공백을 제외한 다른 문자는 제거', () => { - expect(extractHangul('한글과 영어가 섞인 문장입니다. Hello!')).toBe('한글과 영어가 섞인 문장입니다 '); - }); - - it('escape 문자열 유지', () => { - expect(extractHangul('한글과\n\t줄바꿈')).toBe('한글과\n\t줄바꿈'); - }); - - it('모음은 제거하지 않음', () => { - expect(extractHangul('ㅠㅠ')).toBe('ㅠㅠ'); - }); - - it('자음은 제거하지 않음', () => { - expect(extractHangul('ㄱㄴㄱㄴ')).toBe('ㄱㄴㄱㄴ'); - }); -}); diff --git a/src/extractHangul.ts b/src/extractHangul.ts deleted file mode 100644 index d023a674..00000000 --- a/src/extractHangul.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @name extractHangul - * @description - * 문자열을 입력받고 한글만 추출해 반환합니다. - * - * @param {string} chars 모든 문자열 - * - * @example - * extractHangul('안녕하세요1234abc') // '안녕하세요' - * extractHangul('abcde') // '' - * extractHangul('안녕하세요ㄱㄴ') // '안녕하세요ㄱㄴ' - * extractHangul('안녕하세요 만나서 반갑습니다') // '안녕하세요 만나서 반갑습니다' - * extractHangul('가나다!-29~라마바.,,사') // '가나다라마바사' - */ - -export function extractHangul(str: string): string { - return str.replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣\s]+/g, ''); -} diff --git a/src/index.ts b/src/index.ts index 0cb8f2e5..f7ae4aa3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,5 +18,4 @@ export { hasSingleBatchim, hasValueInReadOnlyStringList, } from './utils'; -export { extractHangul } from './extractHangul'; export { acronymizeHangul } from './acronymizeHangul';