Regular Expression not to allow numbers - just Arabic letters

前端 未结 4 1605
猫巷女王i
猫巷女王i 2021-01-30 18:43

I found this regular expression for Arabic letters but it is also allowing numbers with letters. How can I change it to let it allow letters only ?

/[\\u0600-\\u         


        
4条回答
  •  再見小時候
    2021-01-30 19:08

    Probably you'd have to check what range the numbers match and exclude it (formally not include in brackets expression).

    Here I've found another helpful source.

    I'd suggest this for only letters

    /[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]/
    

    as this matches arabic digits only

    /[\u0660-\u0669\u06F0-\u06F9]/
    

    Edit:

    I've found that there are two ranges for arabic and arabic-indic digits in unicode.

    If you need a regex to match a line just then, when it contains arabic letters and numbers - use this:

    /^[\u0600-\u06FF]*$/
    

    If you want to also discourage arabic digits - use this:

    /^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]*$/
    

    If you want to match a substring, not only a whole line, use this:

    /\b[\s\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]*\b/
    

提交回复
热议问题