Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bluewings/korean-regexp
https://github.com/bluewings/korean-regexp
hangul korean regexp
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bluewings/korean-regexp
- Owner: bluewings
- License: mit
- Created: 2020-10-05T13:27:13.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-27T00:37:57.000Z (over 1 year ago)
- Last Synced: 2024-04-14T10:18:28.437Z (8 months ago)
- Topics: hangul, korean, regexp
- Language: TypeScript
- Homepage:
- Size: 113 KB
- Stars: 219
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# korean-regexp
[![npm version](https://badge.fury.io/js/korean-regexp.svg)](https://badge.fury.io/js/korean-regexp)
[한글 자동완성을 위한 정규식](https://bluewings.github.io/unobstructed-hangul-regular-expression/) | 영타 ↔ 한타 변환 | 조사 자동 치환 | 자소 분리, 합치기
### Installation
npm install korean-regexp
### Usage
```js
import {
getRegExp,
engToKor,
korToEng,
correctPostpositions,
explode,
implode,
getPhonemes,
} from 'korean-regexp';// the process of typing '개울가'
getRegExp('ㄱ'); // /[ㄱ가-깋]/i
getRegExp('개'); // /[개-갷]/i
getRegExp('갱'); // /(갱|개[아-잏])/i
getRegExp('개우'); // /개[우-윟]/i
getRegExp('개울'); // /개(울|우[라-맇])/i
getRegExp('개욹'); // /개(욹|울[가-깋])/i
getRegExp('개울가'); // /개울[가-갛]/igetRegExp('ㅊㅅ퀴즈'); // /ㅊㅅ퀴[즈-즿]/i
getRegExp('ㅊㅅ퀴즈', { // /^[ㅊ차-칳]\s*[ㅅ사-싷]\s*퀴\s*[즈-즿]$/g
initialSearch: true,
startsWith: true,
endsWith: true,
ignoreSpace: true,
ignoreCase: false,
global: true,
});
getRegExp('ㅊㅅ퀴즈', { // /[ㅊ차-칳].*[ㅅ사-싷].*퀴.*[즈-즿]/i
initialSearch: true,
fuzzy: true,
});
getRegExp('한글날', { // /한글(?:날|나[라-맇])/i
nonCaptureGroup: true
});engToKor('gksrmfskf'); // 한글날
engToKor('Rkrenrl, xhdekfr'); // 깍두기, 통닭korToEng('ㅗ디ㅣㅐ 재깅!'); // hello world!
korToEng('ㅠㅁ차 새 솓 려셕ㄷ'); // back to the futurecorrectPostpositions('전쟁와(과) 평화'); // 전쟁과 평화
correctPostpositions('고양이은(는) 건드리지 마라'); // 고양이는 건드리지 마라
correctPostpositions('"테스형"이(가) "나훈아"을(를) 만났다'); // "테스형"이 "나훈아"를 만났다explode('한글'); // ['ㅎ', 'ㅏ', 'ㄴ', 'ㄱ', 'ㅡ', 'ㄹ']
explode('한글', { grouped: true }); // [['ㅎ', 'ㅏ', 'ㄴ'], ['ㄱ', 'ㅡ', 'ㄹ']]implode('ㅇㅓㅂㅔㄴㅈㅕㅅㅡ ㅇㅐㄴㄷㅡㄱㅔㅇㅣㅁ'); // 어벤져스 앤드게임
implode(['ㅂ', 'ㅜ', 'ㄹ', 'ㄷ', 'ㅏ', 'ㄹ', 'ㄱ']); // 불닭
implode([['ㅂ', 'ㅜ', 'ㄹ'], ['ㄷ', 'ㅏ', 'ㄹ', 'ㄱ']]); // 불닭getPhonemes('한');
// {
// initial: 'ㅎ',
// medial: 'ㅏ',
// finale: 'ㄴ',
// initialOffset: 18,
// medialOffset: 0,
// finaleOffset: 4
// }
```