From cd928957b27dbda7cd142ec24707df0a09ea1731 Mon Sep 17 00:00:00 2001 From: chanhyuk-park Date: Sat, 13 Jul 2024 00:26:35 +0900 Subject: [PATCH 1/2] remove extrachHangul --- 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 - 5 files changed, 92 deletions(-) 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/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 5e839a05..950d7ed3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,5 +17,4 @@ export { hasSingleBatchim, hasValueInReadOnlyStringList, } from './utils'; -export { extractHangul } from './extractHangul'; export { acronymizeHangul } from './acronymizeHangul'; From 85e66bf79c21a9761a3ffab2a0fdf449920bf00d 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 15:35:24 +0900 Subject: [PATCH 2/2] Create cyan-tigers-sneeze.md --- .changeset/cyan-tigers-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cyan-tigers-sneeze.md 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 함수를 제거합니다