I work with MVC and I am new on it. I want to check input values is only in Persian language (Characters) by [RegularExpression]
Validation.
So I think to use Regex and need to check in range of unicodes, but I don't lnow how can find range of Persian characters Unicode. Am I right about this Regex? what is your suggestion and how can I find range of Unicode in Persian
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Check first letter and last letter range in Persian I think something like this:
This Only Contain standard Arabic symbols range But Persian also include 4 More Characters:
So You Should Use:
If you want to match Zero-width-non-joiner you should add this too:
Persian characters are within the range:
[\u0600-\u06FF]
Try:
I use this RegExp in my program, and it works correctly. hope to help you:
Persian characters are within the range: [\u0600-\u06FF] + [\s]
Try:
This Patern Contains Letter and space Charachters.
TL;DR
All answers that say use
\u0600-\u06FF
or[آ-ی]
are simply WRONG.Farsi MUST used character sets are as following:
Use
^[آابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$
for letters.Use
^[۰۱۲۳۴۵۶۷۸۹]+$
for numbers.Use
[ ٌ ًّ َ ِ ُ ْ ]
for vowels.Or a union of those. You may want to add other Arabic letters like Hamza
ء
to your character set additionally.This answer exists to fix a common misconception. Codepoints
0600
through06FF
do not denote Persian / Farsi alphabet (neither does[آ-ی]
):255 characters are fallen in this range, Farsi alphabet has 32 letters that in addition to Farsi demonstration of digits it would be 42. If we add vowels (Arabic vowels originally, that rarely used in Farsi) and Tanvin (
ً
,ٍِ
,ٌ
) and Tashdid (ّ
) that are both a subset of Arabic diacritics not Farsi, we'd end with 46 characters. This means:\u0600-\u06FF
contains 209 more characters than you need!۷
with codepoint06F7
is a Farsi representation of number7
and٧
with codepoint0667
is Arabic representation of the same number.۶
is Farsi representation of number6
and٦
is Arabic representation of the same number. And all reside in0600
through06FF
codepoints.You can see different number of other characters that doesn't exist in Farsi / Persian too and nobody is willing to have them while validating a first name or surname.
[آ-ی]
includes 117 characters too which is much more than what someone needs for validation. You can see them all using Unicode CLDR.