Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created August 26, 2013 11:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/6340626 to your computer and use it in GitHub Desktop.
Save yairEO/6340626 to your computer and use it in GitHub Desktop.
Check if a character is RTL or LTR
function isRTL(s){
var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF'+'\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
rtlDirCheck = new RegExp('^[^'+ltrChars+']*['+rtlChars+']');
return rtlDirCheck.test(s);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment