Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

unicode-regex

ikatyang-collab249.7kMIT4.1.2TypeScript support: included

regular expression for matching unicode category

regular-expression, unicode

readme

unicode-regex

npm build

regular expression for matching unicode category.

Changelog

Install

npm install unicode-regex

Usage

import unicode from 'unicode-regex'

const regex = unicode({ General_Category: ['Punctuation'] }).toRegExp()
regex.test('a') //=> false
regex.test('"') //=> true
regex.test('“') //=> true

API

declare function unicode(categories: {
  [category: string]: SubCategory[]
}): Charset

Returns a Charset for further processing, e.g. union, intersect, etc.

(Data from node-unicode-data)

Development

# lint
pnpm run lint

# build
pnpm run build

# test
pnpm run test

License

MIT © Ika

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

4.1.2 (2025-03-08)

4.1.1 (2025-03-08)

4.1.0 (2025-03-07)

Features

4.0.0 (2023-07-09)

Build System

Features

BREAKING CHANGES

  • upgrade Unicode data from v12.1.0 to v15.0.0
  • this package is now pure ESM

3.0.0 (2019-09-29)

Features

BREAKING CHANGES

  • upgrade Unicode data from v10.0.0 to v12.1.0

2.0.0 (2018-02-09)

Features

  • rewrite with node-unicode-data and regexp-util (#57) (c26d703)

BREAKING CHANGES

More categories, processable output, and adding codepoints that's greater than 0xffff.

// before
unicode_regex(['Pc', 'Pd', 'Pe', 'Pf', 'Pi', 'Po', 'Ps'])

// after
unicode({ General_Category: ['Punctuation'] }).toRegExp()

1.0.1 (2017-11-12)

Bug Fixes

1.0.0 (2017-11-12)

Features