TooTallNate / pcre-to-regexp

Converts PCRE regexp strings to JavaScript RegExp instances
MIT License
22 stars 6 forks source link

ERROR SyntaxError: Invalid regular expression: /[\x{0600}-\x{06FF}]/: Range out of order in character class #8

Open Dok11 opened 4 years ago

Dok11 commented 4 years ago

But /[\x{0600}-\x{06FF}]/ is valid PCRE

Dok11 commented 4 years ago

My hotfix:

const hexRangeRegExp = new RegExp(/\\x\{([\dabcdef]{4})\}-\\x\{([\dabcdef]{4})\}/ig);
const fixedPattern = pattern.replace(hexRangeRegExp, '\\u$1-\\u$2');

pcre(fixedPattern, []);

i think [\dabcdef]{4} may be replace to better pattern.