https://github.com/shinnn/non-4byte-chars-regex
Regular expression that matches a string with no 4-byte characters
https://github.com/shinnn/non-4byte-chars-regex
Last synced: about 1 month ago
JSON representation
Regular expression that matches a string with no 4-byte characters
- Host: GitHub
- URL: https://github.com/shinnn/non-4byte-chars-regex
- Owner: shinnn
- License: unlicense
- Created: 2016-11-08T10:11:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-08T10:20:41.000Z (about 9 years ago)
- Last Synced: 2025-09-04T11:28:05.024Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# non-4byte-chars-regex
[](https://www.npmjs.com/package/non-4byte-chars-regex)
[](https://github.com/shinnn/non-4byte-chars-regex/releases)
[](https://travis-ci.org/shinnn/non-4byte-chars-regex)
[](https://david-dm.org/shinnn/non-4byte-chars-regex?type=dev)
[Regular expression](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp) which matches a string with no [4-byte characters](https://github.com/shinnn/is-4byte-char/)
```javascript
/^(?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*$/
```
## Installation
### [npm](https://www.npmjs.com/)
```
npm install non-4byte-chars-regex
```
### [bower](https://bower.io/)
```
bower install non-4byte-chars-regex
```
## API
### non4byteCharsRegex
Type: `RegExp`
```javascript
import non4byteCharsRegex from 'non-4byte-chars-regex';
non4byteCharsRegex.test('foo'); //=> true
non4byteCharsRegex.test('bar🍣baz'); //=> false
non4byteCharsRegex.test('吉'); //=> true
non4byteCharsRegex.test('𠮷'); //=> false
```
## License
[The Unlicense](./LICENSE)