UNPKG

ts-regex-builder

Version:

Maintainable regular expressions for TypeScript and JavaScript.

26 lines (25 loc) 795 B
"use strict"; exports.char = void 0; exports.unicodeChar = unicodeChar; exports.unicodeProperty = unicodeProperty; function unicodeChar(codePoint) { if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) { throw new RangeError(`Expected a valid unicode code point but received ${codePoint}`); } let escape = codePoint < 0x10000 ? `\\u${codePoint.toString(16).padStart(4, '0')}` : `\\u{${codePoint.toString(16)}}`; return { precedence: 'atom', pattern: escape, chars: [escape] }; } const char = exports.char = unicodeChar; function unicodeProperty(property, value) { const escape = `\\p{${property}${value ? `=${value}` : ''}}`; return { precedence: 'atom', pattern: escape, chars: [escape] }; } //# sourceMappingURL=unicode.js.map