fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 41 lines 1.3 kB view raw
1/** 2 * Matches characters from the start that are not valid Python identifier starts. 3 * Python identifiers: starts with letter/underscore, followed by letters/digits/underscores. 4 */ 5const illegalStartCharactersRegExp = /^[^a-zA-Z_]+/; 6 7/** 8 * Matches if string contains only digits and optionally decimal point or leading minus. 9 */ 10const numberRegExp = /^-?\d+(\.\d+)?$/; 11 12/** 13 * Python identifier pattern: starts with letter or underscore, 14 * followed by letters, digits, or underscores. 15 * Uses Unicode categories for full Python 3 compliance. 16 */ 17const validPythonIdentifierRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/u; 18 19/** 20 * Matches if a string looks like a valid Python identifier. 21 */ 22const looksLikeIdentifierRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/; 23 24export const regexp = { 25 /** 26 * Matches characters from the start that are not valid Python identifier starts. 27 */ 28 illegalStartCharacters: illegalStartCharactersRegExp, 29 /** 30 * Simpler pattern for quick identifier checks. 31 */ 32 looksLikeIdentifier: looksLikeIdentifierRegExp, 33 /** 34 * Matches if string contains only digits and optionally decimal point or leading minus. 35 */ 36 number: numberRegExp, 37 /** 38 * Python identifier pattern for validation. 39 */ 40 pythonIdentifier: validPythonIdentifierRegExp, 41};