[ACCEPTED]-Javascript - how to find hebrew?-right-to-left

Accepted answer
Score: 33

This will find hebrew letters encoded in 1 the Hebrew Unicode code point range: [\u0590-\u05FF]

Score: 25

JavaScript does not support regex scripts 4 like \p{InHebrew} (or something similar). However, it 3 does support Unicode escapes, so you could 2 use a regex like:

/[\u0590-\u05FF]/

which will match a single 1 Hebrew character.

See: http://unicode.org/charts/PDF/U0590.pdf and: http://www.regular-expressions.info/unicode.html

Score: 14

    function is_heb(Field) {
        // 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;
        } else
            return true;
    }
<input id="the_text" type="text" value="בדיקה" />
<br /><button onclick="document.getElementById('the_result').value = is_heb(document.getElementById('the_text').value)">Is it Hebrew?</button>
<br /><br />
Result:
<br /><input id="the_result" type="text">

0

Score: 4

if (str.charCodeAt(0) >= 0x590) && (str.charCodeAt(0) <= 0x5FF) then it is considered a hebrew character

0

Score: 0

Especially for Hebrew the question is answered 6 already - regarding all ranges:

Especially 5 for JS I would recommend a tool to build 4 your regex - see Unicode range RegExp generator (Compiles character ranges 3 suitable for use in JavaScript)

[ just select 2 hebrew or the scripts or ranges you want 1 ]

More Related questions