non-4byte-chars-regex
v1.0.0
Published
Regular expression which matches a string with no 4-byte characters
Downloads
8,625
Maintainers
Readme
non-4byte-chars-regex
Regular expression which matches a string with no 4-byte characters
/^(?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*$/
Installation
npm
npm install non-4byte-chars-regex
bower
bower install non-4byte-chars-regex
API
non4byteCharsRegex
Type: RegExp
import non4byteCharsRegex from 'non-4byte-chars-regex';
non4byteCharsRegex.test('foo'); //=> true
non4byteCharsRegex.test('bar🍣baz'); //=> false
non4byteCharsRegex.test('吉'); //=> true
non4byteCharsRegex.test('𠮷'); //=> false