I'm trying to implement a simple function of detecting whether a string contains Hebrew characters using js. HELP!
Edit: I'm not interested in detecting a rtl language, just Hebrew.
you need to use this regular expression to search in your string ."/[\u0590-\u05FF]/" i.e.
function contains_heb(str) {
return (/[\u0590-\u05FF]/).test(str);
}
<input id="the_text" type="text" value="בדיקה" />
<br /><button onclick="document.getElementById('the_output').value = contains_heb(document.getElementById('the_text').value)">Does it contain Hebrew?</button>
<br /><br />
Output:
<br /><input id="the_output" type="text" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With