i "m tries to trick if a line begins (first letter), width of RTL language / Hebrew.
any ideas?
Hebrew letters encoded in Hebrew will be found here. Unicode Code Range: [\u0590-\u05FF]
[\u0590-\u05FF]
JavaScript does not support regular expression scripts such as \p{InHebrew} (or something similar). However, it supports Unicode escapes, so you can use regular expressions like:
\p{InHebrew}
/[\u0590-\u05FF]/
which will correspond to one character in Hebrew.
See: http://unicode.org/charts/PDF/U0590.pdf and: http://www.regular-expressions.info/unicode.html
// First choose the required validation HebrewChars = new RegExp("^[\u0590-\u05FF]+$"); AlphaNumericChars = new RegExp("^[a-zA-Z0-9\-]+$"); EnglishChars = new RegExp("^[a-zA-Z\-]+$"); LegalChars = new RegExp("^[a-zA-Z\-\u0590-\u05FF ]+$"); //Note that this one allows space // Then use it if (!LegalChars.test(Field)) { return false; }
if (str.charCodeAt(0) >= 0x590) && (str.charCodeAt(0) <= 0x5FF) then is considered a gay symbol
if (str.charCodeAt(0) >= 0x590) && (str.charCodeAt(0) <= 0x5FF) then
Especially for Hebrew, the question already answers - regarding all ranges:
Specially for JS, I would recommend a tool for creating your regular expression - see Unicode range RegExp generator (Composes character ranges suitable for use in JavaScript)
[just select the Hebrew or scripts or ranges that you want)