Git Product home page Git Product logo

korean-regexp's Introduction

korean-regexp

npm version

한글 자동완성을 위한 정규식 | 영타 ↔ 한타 변환 | 조사 자동 치환 | 자소 분리, 합치기

Installation

npm install korean-regexp

Usage

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('개울가');  // /개울[가-갛]/i

getRegExp('ㅊㅅ퀴즈');   // /ㅊㅅ퀴[즈-즿]/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 future

correctPostpositions('전쟁와(과) 평화');  // 전쟁과 평화
correctPostpositions('고양이은(는) 건드리지 마라');  // 고양이는 건드리지 마라
correctPostpositions('"테스형"이(가) "나훈아"을(를) 만났다');  // "테스형"이 "나훈아"를 만났다

explode('한글');                     // ['ㅎ', 'ㅏ', 'ㄴ', 'ㄱ', 'ㅡ', 'ㄹ']
explode('한글', { grouped: true });  // [['ㅎ', 'ㅏ', 'ㄴ'], ['ㄱ', 'ㅡ', 'ㄹ']]

implode('ㅇㅓㅂㅔㄴㅈㅕㅅㅡ ㅇㅐㄴㄷㅡㄱㅔㅇㅣㅁ');  // 어벤져스 앤드게임
implode(['ㅂ', 'ㅜ', 'ㄹ', 'ㄷ', 'ㅏ', 'ㄹ', 'ㄱ']);  // 불닭
implode([['ㅂ', 'ㅜ', 'ㄹ'], ['ㄷ', 'ㅏ', 'ㄹ', 'ㄱ']]);  // 불닭

getPhonemes('한');
// {
//   initial: 'ㅎ',
//   medial: 'ㅏ',
//   finale: 'ㄴ',
//   initialOffset: 18,
//   medialOffset: 0,
//   finaleOffset: 4
// }

korean-regexp's People

Contributors

bluewings avatar flex-hyuntae avatar hooriza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

korean-regexp's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.