Regex with better distinction between LTR and RTL characters

Co-authored-by: MoonE <maxi_kroeg@web.de>
This commit is contained in:
Andreas Hocevar
2020-11-15 08:59:43 +01:00
committed by GitHub
parent 7cc45c967b
commit 7232001d9f

View File

@@ -75,7 +75,17 @@ function getDeclutterBox(replayImageOrLabelArgs) {
return replayImageOrLabelArgs[3].declutterBox;
}
const rtlRegEx = /[\u0591-\u07FF]/;
const rtlRegEx = new RegExp(
/* eslint-disable prettier/prettier */
'[' +
String.fromCharCode(0x00591) + '-' + String.fromCharCode(0x008ff) +
String.fromCharCode(0x0fb1d) + '-' + String.fromCharCode(0x0fdff) +
String.fromCharCode(0x0fe70) + '-' + String.fromCharCode(0x0fefc) +
String.fromCharCode(0x10800) + '-' + String.fromCharCode(0x10fff) +
String.fromCharCode(0x1e800) + '-' + String.fromCharCode(0x1efff) +
']'
/* eslint-enable prettier/prettier */
);
/**
* @param {string} text Text.