UNPKG

ts-regex-builder

Version:

Maintainable regular expressions for TypeScript and JavaScript.

32 lines (31 loc) 1.44 kB
import type { CharacterEscape } from '../types'; /** * Unicode character code point escape. * * Regex pattern: * - `\uXXXX`: 4-digit hex escape for code points below 0x10000. * - `\u{X}`: Unicode code point escape for code points above 0xFFFF. * * Note: for code points above 0xFFFF, the regex must be [unicode-aware](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode#unicode-aware_mode). * * @param codePoint The code point of the character to escape. * @returns A character class representing the unicode escape. */ export declare function unicodeChar(codePoint: number): CharacterEscape; /** * Alias for `unicodeChar`. */ export declare const char: typeof unicodeChar; /** * Unicode property escape matching a set of characters specified by a Unicode property. * * Regex pattern: `\p{Property}` or `\p{Property=Value}` * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape * * Note: the regex must be [unicode-aware](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode#unicode-aware_mode). * * @param property Unicode property name. * @param value Unicode property value (optional). * @returns A character class representing the unicode property escape. */ export declare function unicodeProperty(property: string, value?: string): CharacterEscape;