# xregexp-plugin-hanzi-cjk

> add regexp-cjk plugin for xregexp, make xregexp auto match chinese/japanese hanzi.

Latest version **1.0.59** (published 2026-09-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install xregexp-plugin-hanzi-cjk
pnpm add xregexp-plugin-hanzi-cjk
yarn add xregexp-plugin-hanzi-cjk
bun add xregexp-plugin-hanzi-cjk
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.59 |
| Published | 2026-09-06 |
| First published | 2018-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | chinese, cjk, hanzi, jp, regex, regexp, regexp-cjk, regular expression, xregexp, zh |

## Links

- npm: https://www.npmjs.com/package/xregexp-plugin-hanzi-cjk
- Repository: https://github.com/bluelovers/ws-regexp
- Homepage: https://github.com/bluelovers/ws-regexp/tree/master/packages/xregexp-plugin-hanzi-cjk#readme
- Issues: https://github.com/bluelovers/ws-regexp/issues
- npm.io page: https://npm.io/package/xregexp-plugin-hanzi-cjk

## Recent versions

- 1.0.59 (latest) — 2026-09-06
- 1.0.58 — 2026-09-06
- 1.0.57 — 2026-09-06
- 1.0.56 — 2025-03-12
- 1.0.55 — 2024-09-03
- 1.0.54 — 2024-09-02
- 1.0.53 — 2024-08-24
- 1.0.52 — 2024-03-01
- 1.0.51 — 2024-02-28
- 1.0.50 — 2024-01-29
- 1.0.49 — 2023-02-28
- 1.0.48 — 2022-10-29
- 1.0.47 — 2022-10-26
- 1.0.46 — 2022-10-16
- 1.0.45 — 2022-02-04
- … 38 more at https://npm.io/package/xregexp-plugin-hanzi-cjk/versions

## README

# xregexp-plugin-hanzi-cjk

    add regexp-cjk plugin for xregexp, make xregexp auto match chinese/japanese hanzi.

see [regexp-cjk](https://www.npmjs.com/package/regexp-cjk)

## install

```bash
# 使用 yarn / Using yarn
yarn add xregexp-plugin-hanzi-cjk

# 使用 yarn-tool / Using yarn-tool
yarn-tool add xregexp-plugin-hanzi-cjk
# yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
yt add xregexp-plugin-hanzi-cjk

# 使用 pnpm / Using pnpm
pnpm add xregexp-plugin-hanzi-cjk

# 使用 npm / Using npm
npm install xregexp-plugin-hanzi-cjk
```

## demo

```ts
import addSupportToXRegExp, { IOptions, createXRegExp } from 'xregexp-plugin-hanzi-cjk';
import XRegExp from 'xregexp';
```

```ts
let options: IOptions = {
	// set a flag if u only wanna trigger for this plugin, default is auto enable
	//flags: 'u',
};

console.log(XRegExp.version);

// if didn't set xr, it is XRegExp
const xr1 = addSupportToXRegExp(null, options);
//const xr2 = addSupportToXRegExp(XRegExp, options);
//console.log('xr1 = xr2 = XRegExp', xr1 === xr2);

// XRegExp only work when input pattern is string
let r1 = '(の|像)';
let r2 = /(の|像)/;

let x1 = xr1(r1);

console.log(x1);
console.log(x1.test('象'));
console.log(x1.test('的'));

// this allow u input a RegExp
let x3 = createXRegExp(r2);

console.log(x3);
console.log(x3.test('象'));
console.log(x3.test('的'));

// @BUG current XRegExp not support input pattern ia a RegExp object
let x2 = xr1(r2);

console.error(x2);
console.error(x2.test('象'));
console.error(x2.test('的'));
```

### output

```ts
4.1.1
{ /([の之的]|[像象])/ xregexp: { captureNames: null, source: '(の|像)', flags: '' } }
true
true
{ /([の之的]|[像象])/ xregexp: { captureNames: null, source: '(の|像)', flags: '' } }
true
true
{ /(の|像)/ xregexp: { captureNames: null, source: null, flags: null } }
false
false
```

---
_Source: https://npm.io/package/xregexp-plugin-hanzi-cjk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
