https://github.com/ikatyang-collab/unicode-regex
regular expression for matching unicode category
https://github.com/ikatyang-collab/unicode-regex
regular-expression unicode
Last synced: about 1 year ago
JSON representation
regular expression for matching unicode category
- Host: GitHub
- URL: https://github.com/ikatyang-collab/unicode-regex
- Owner: ikatyang-collab
- License: mit
- Created: 2017-11-12T07:58:07.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T15:30:27.000Z (about 1 year ago)
- Last Synced: 2025-04-19T12:13:46.000Z (about 1 year ago)
- Topics: regular-expression, unicode
- Language: TypeScript
- Size: 320 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# unicode-regex
[](https://www.npmjs.com/package/unicode-regex)
[](https://github.com/ikatyang/unicode-regex/actions?query=branch%3Amain)
regular expression for matching unicode category.
[Changelog](https://github.com/ikatyang/unicode-regex/blob/main/CHANGELOG.md)
## Install
```sh
npm install unicode-regex
```
## Usage
```js
import unicode from 'unicode-regex'
const regex = unicode({ General_Category: ['Punctuation'] }).toRegExp()
regex.test('a') //=> false
regex.test('"') //=> true
regex.test('“') //=> true
```
## API
```ts
declare function unicode(categories: {
[category: string]: SubCategory[]
}): Charset
```
Returns a [Charset](https://github.com/ikatyang/regexp-util#charset) for further processing, e.g. union, intersect, etc.
(Data from [`node-unicode-data`](https://github.com/mathiasbynens/node-unicode-data))
## Development
```sh
# lint
pnpm run lint
# build
pnpm run build
# test
pnpm run test
```
## License
MIT © [Ika](https://github.com/ikatyang)