How to regex match entire string instead of a single character

前端 未结 2 762
暖寄归人
暖寄归人 2021-01-21 09:25

I am trying to implement \"alpha\" validation on Arabic alphabet characters input, using the JavaScript regex /[\\u0600-\\u06FF]/ as instructed in this post. I want

2条回答
  •  清歌不尽
    2021-01-21 09:45

    You need to add ^ and $ anchors to the regular expression, as well as a + to allow multiple characters.

    Try this:

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

    I'm not sure if "Arabic spaces" that you mentioned are included in the character range there, but if you want to allow white space in the string then just add a \s inside the [] brackets.

提交回复
热议问题