'Regex to match Hebrew and English characters except numbers
I have a question: I want to do a validation for the first and the last name with RegEx. I want to do it with only Hebrew and English without numbers. Someone can help me to do that code?
Solution 1:[1]
Seemingly Hebrew has the range \u0590-\u05fe (according to this nice JavaScript Unicode Regex generator`.
/^[a-z\u0590-\u05fe]+$/i
Solution 2:[2]
While the selected answer is correct about "Hebrew" the OP wanted to limit validation to only Hebrew and English letters. The Hebrew Unicode adds a lot of punctuation and symbols (as you can see in the table here) irrelevant for such validation. If you want only Hebrew letters (along with English letters) the regex would be:
/^[a-z\u05D0-\u05EA]+$/i
I would consider adding ' (single quote) as well, for foreign consonants that are missing in Hebrew (such as G in George and Ch in Charlie) make use of it along with a letter:
/^[a-z\u05D0-\u05EA']+$/i
Solution 3:[3]
English & Hebrew FULL regex
I'm using the above regex on my application. My users are just fine with it:
RegExp(r'^[a-zA-Z\u0590-\u05FF\u200f\u200e ]+$');
The regex supports:
- English letters (includes Capital letters).
a-zA-Z - Hebrew (includes special end-letters).
\u0590-\u05FF - change direction unicodes (RLM, LRM).
\u200f\u200e - White space.
Enjoy!
Solution 4:[4]
Try this. Not sure if it will work. If not, these references should help.
[A-Za-z\u0590-\u05FF]*
Solution 5:[5]
Hebrew letters only:
/^[\u0590-\u05ea]+$/i
Solution 6:[6]
You can also use \p{Hebrew} in your regex to detect any Hebrew unicode characters (if you're regex engine supports it).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Tom Shmaya |
| Solution 3 | |
| Solution 4 | Strongbeard |
| Solution 5 | Jonesome Reinstate Monica |
| Solution 6 | Professional_Helper |
