Skip to content

Instantly share code, notes, and snippets.

@wyl8899
wyl8899 / spacing.ts
Created September 29, 2020 17:48
JavaScript 实现中英文空格 - Implementation
/* Partial implementation from https://zhuanlan.zhihu.com/p/33612593 */
import _ from 'lodash';
/* 标点 */
const punctuationRegex = /\p{Punctuation}/u;
/* 空格 */
const spaceRegex = /\p{Separator}/u;
/* CJK 字符,中日韩 */
const cjkRegex = /\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}|\p{Script=Hangul}/u;