Regular Expression Arabic characters and numbers only

后端 未结 11 942
梦毁少年i
梦毁少年i 2020-11-27 02:44

I want Regular Expression to accept only Arabic characters, Spaces and Numbers.

Numbers are not required to be in

相关标签:
11条回答
  • 2020-11-27 03:04

    With a lot of try and edit i got this for Persian names:

    [گچپژیلفقهمو ء-ي]+$
    
    0 讨论(0)
  • 2020-11-27 03:07

    In PHP, use this:

    preg_replace("/\p{Arabic}/u", 'x', 'abc123ابت');// will replace arabic letters with "x".
    

    Note: For \p{Arabic} to match arabic letters, you need to pass u modifier (for unicode) at the end.

    0 讨论(0)
  • 2020-11-27 03:08

    ^[\u0621-\u064Aa-zA-Z\d\-_\s]+$

    This regex must accept Arabic letters,English letters, spaces and numbers

    0 讨论(0)
  • 2020-11-27 03:13
    [\p{IsArabic}-[\D]]
    

    An Arabic character that is not a non-digit

    0 讨论(0)
  • 2020-11-27 03:17

    you can use [ء-ي] it worked for me in javascript Jquery forme.validate rules

    for my example I want to force user to insert 3 characters

    [a-zA-Zء-ي]

    0 讨论(0)
  • 2020-11-27 03:18

    Just add 1-9 (in Unicode format) to your character-class:

    ^[\u0621-\u064A0-9 ]+$
    

    OR add \u0660-\u0669 to the character-class which is the range of Arabic numbers :

    ^[\u0621-\u064A\u0660-\u0669 ]+$
    
    0 讨论(0)
提交回复
热议问题