Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikatyang/unicode-regex
regular expression for matching unicode category
https://github.com/ikatyang/unicode-regex
regular-expression unicode
Last synced: 3 months ago
JSON representation
regular expression for matching unicode category
- Host: GitHub
- URL: https://github.com/ikatyang/unicode-regex
- Owner: ikatyang
- License: mit
- Created: 2017-11-12T07:58:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T13:32:10.000Z (8 months ago)
- Last Synced: 2024-10-30T03:44:42.606Z (3 months ago)
- Topics: regular-expression, unicode
- Language: TypeScript
- Size: 287 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# unicode-regex
[![npm](https://img.shields.io/npm/v/unicode-regex.svg)](https://www.npmjs.com/package/unicode-regex)
[![build](https://img.shields.io/github/actions/workflow/status/ikatyang/unicode-regex/test.yml)](https://github.com/ikatyang/unicode-regex/actions?query=branch%3Amaster)regular expression for matching unicode category.
[Changelog](https://github.com/ikatyang/unicode-regex/blob/master/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)